Intro

In this script, I take the collated stomach data set and calculate aggregates (feeding ratio, total weight of prey groups) and predictor variables for diet data, aggregate to get 1 stomach = 1 row per prey type (not prey individual). I also select only the columns I need for model fitting, join environmental covariates and cpue covariates for cod and flounder, and lastly saduria biomass densities.

Load packages & source functions

# Load libraries, install if needed
library(tidyverse)
#> Warning: package 'tidyr' was built under R version 4.0.5
library(readxl)
library(tidylog)
library(RCurl)
library(RColorBrewer)
#> Warning: package 'RColorBrewer' was built under R version 4.0.5
library(patchwork)
library(janitor)
library(forcats)
library(gapminder)
library(viridis)
library(ggridges)
library(raster)
library(icesDatras)
library(ggalluvial)
library(ggrepel)
library(ncdf4)
library(chron)
library(rnaturalearth)
library(rnaturalearthdata)
library(mapplots)
library(geosphere)
library(quantreg)
#> Warning in .recacheSubclasses(def@className, def, env): undefined subclass
#> "numericVector" of class "Mnumeric"; definition not updated
library(brms)
#> Warning: package 'Rcpp' was built under R version 4.0.5
library(sdmTMB)
options(mc.cores = parallel::detectCores()) 

world <- ne_countries(scale = "medium", returnclass = "sf")

# Source code for map plots
source("/Users/maxlindmark/Dropbox/Max work/R/cod_interactions/R/functions/map_plot.R")

# Load cache
# qwraps2::lazyload_cache_dir(path = "R/prepare_data/03_clean_stomach_data_cache/html")

theme_set(theme_plot())

# Continuous colors
options(ggplot2.continuous.colour = "viridis")

# Discrete colors
scale_colour_discrete <- function(...) {
  scale_colour_brewer(palette = "Paired")
}

scale_fill_discrete <- function(...) {
  scale_fill_brewer(palette = "Paired")
}

Read data

d <- read_csv("data/clean/full_stomach_data.csv") %>%
  dplyr::select(-...1) 
#> New names:
#> Rows: 57730 Columns: 42
#> ── Column specification
#> ──────────────────────────────────────────────────────── Delimiter: "," chr
#> (18): prey_latin_name, comment, country, cruise, predator_code, stomach... dbl
#> (22): ...1, year, day, prey_length_cm, prey_weight_g, stage_digestion, ... lgl
#> (1): size_group_code date (1): date
#> ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
#> Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> • `` -> `...1`

Plot data

head(data.frame(d))
#>   year day    prey_latin_name prey_length_cm prey_weight_g stage_digestion
#> 1 2015  NA Monoporeia affinis             NA    0.01176923               1
#> 2 2015  NA Monoporeia affinis             NA    0.01176923               1
#> 3 2015  NA Monoporeia affinis             NA    0.01176923               1
#> 4 2015  NA Monoporeia affinis             NA    0.01176923               1
#> 5 2015  NA Monoporeia affinis             NA    0.01176923               1
#> 6 2015  NA Monoporeia affinis             NA    0.01176923               1
#>   comment quarter country cruise size_group_code pred_weight_g predator_code
#> 1    <NA>       4     SWE   BITS              NA        106.48           FLE
#> 2    <NA>       4     SWE   BITS              NA        106.48           FLE
#> 3    <NA>       4     SWE   BITS              NA        106.48           FLE
#> 4    <NA>       4     SWE   BITS              NA        106.48           FLE
#> 5    <NA>       4     SWE   BITS              NA        106.48           FLE
#> 6    <NA>       4     SWE   BITS              NA        106.48           FLE
#>   stomach_state sample    data_id        pred_id       date month haul validity
#> 1          <NA>    160 2015_4_FLE 2015_4_FLE_160 2015-11-21    11    8        V
#> 2          <NA>    160 2015_4_FLE 2015_4_FLE_160 2015-11-21    11    8        V
#> 3          <NA>    160 2015_4_FLE 2015_4_FLE_160 2015-11-21    11    8        V
#> 4          <NA>    160 2015_4_FLE 2015_4_FLE_160 2015-11-21    11    8        V
#> 5          <NA>    160 2015_4_FLE 2015_4_FLE_160 2015-11-21    11    8        V
#> 6          <NA>    160 2015_4_FLE 2015_4_FLE_160 2015-11-21    11    8        V
#>                 station_name subdiv weight                   specimen_note
#> 1 4 SE NORRA MIDSJ\xd6BANKEN     25    138 Mags\xe4ck sparad f\xf6r analys
#> 2 4 SE NORRA MIDSJ\xd6BANKEN     25    138 Mags\xe4ck sparad f\xf6r analys
#> 3 4 SE NORRA MIDSJ\xd6BANKEN     25    138 Mags\xe4ck sparad f\xf6r analys
#> 4 4 SE NORRA MIDSJ\xd6BANKEN     25    138 Mags\xe4ck sparad f\xf6r analys
#> 5 4 SE NORRA MIDSJ\xd6BANKEN     25    138 Mags\xe4ck sparad f\xf6r analys
#> 6 4 SE NORRA MIDSJ\xd6BANKEN     25    138 Mags\xe4ck sparad f\xf6r analys
#>    species  haul_id fle_kg_km2 lcod_kg_km2 scod_kg_km2      lat      lon depth
#> 1 Flounder 2015_4_8   794.8598    5514.953    2626.168 56.06667 17.36667  41.6
#> 2 Flounder 2015_4_8   794.8598    5514.953    2626.168 56.06667 17.36667  41.6
#> 3 Flounder 2015_4_8   794.8598    5514.953    2626.168 56.06667 17.36667  41.6
#> 4 Flounder 2015_4_8   794.8598    5514.953    2626.168 56.06667 17.36667  41.6
#> 5 Flounder 2015_4_8   794.8598    5514.953    2626.168 56.06667 17.36667  41.6
#> 6 Flounder 2015_4_8   794.8598    5514.953    2626.168 56.06667 17.36667  41.6
#>             prey_number_type prey_weight_type pred_length_cm
#> 1 un_aggregated_from_average           pooled             22
#> 2 un_aggregated_from_average           pooled             22
#> 3 un_aggregated_from_average           pooled             22
#> 4 un_aggregated_from_average           pooled             22
#> 5 un_aggregated_from_average           pooled             22
#> 6 un_aggregated_from_average           pooled             22
#>      pred_weight_source ices_rect        X        Y predator_latin_name
#> 1 estimated_from_length      41G7 647.3339 6216.025  Platichthys flesus
#> 2 estimated_from_length      41G7 647.3339 6216.025  Platichthys flesus
#> 3 estimated_from_length      41G7 647.3339 6216.025  Platichthys flesus
#> 4 estimated_from_length      41G7 647.3339 6216.025  Platichthys flesus
#> 5 estimated_from_length      41G7 647.3339 6216.025  Platichthys flesus
#> 6 estimated_from_length      41G7 647.3339 6216.025  Platichthys flesus

plot_map_labels_fc +
  geom_point(data = filter(d, species == "Cod"), aes(x = X*1000, y = Y*1000), size = 0.5) +
  facet_grid(quarter~year) +
  ggtitle("Cod")
#> filter: removed 34,111 rows (59%), 23,619 rows remaining


plot_map_labels_fc +
  geom_point(data = filter(d, species == "Flounder"), aes(x = X*1000, y = Y*1000), size = 0.5) +
  facet_grid(quarter~year) +
  ggtitle("Flounder")
#> filter: removed 23,619 rows (41%), 34,111 rows remaining

Summarize and organize data

We want 1 row = 1 predator and the total weight for each present prey type

# Calculate total weight of prey by predator ID and prey species (i.e., across prey sizes). First create wide data frame so that I can sum easily across prey groups (columns)
d_wide <- d %>% 
  drop_na(prey_weight_g) %>%
  group_by(pred_id, prey_latin_name) %>% 
  summarise(tot_prey_weight_g = sum(prey_weight_g)) %>% 
  ungroup() %>% 
  pivot_wider(names_from = prey_latin_name, values_from = tot_prey_weight_g) %>% 
  mutate_all(~ifelse(is.na(.), 0, .)) %>% 
  clean_names()
#> drop_na: removed 201 rows (<1%), 57,529 rows remaining
#> group_by: 2 grouping variables (pred_id, prey_latin_name)
#> summarise: now 11,088 rows and 3 columns, one group variable remaining (pred_id)
#> ungroup: no grouping variables
#> pivot_wider: reorganized (prey_latin_name, tot_prey_weight_g) into (Diastylis rathkei, Halicryptus spinulosus, Bylgides sarsi, NA, Clupeidae, …) [was 11088x3, now 5889x95]
#> mutate_all: changed 5,099 values (87%) of 'Diastylis rathkei' (5099 fewer NA)
#>             changed 5,324 values (90%) of 'Halicryptus spinulosus' (5324 fewer NA)
#>             changed 5,432 values (92%) of 'Bylgides sarsi' (5432 fewer NA)
#>             changed 4,354 values (74%) of 'NA' (4354 fewer NA)
#>             changed 5,655 values (96%) of 'Clupeidae' (5655 fewer NA)
#>             changed 5,300 values (90%) of 'Sprattus sprattus' (5300 fewer NA)
#>             changed 4,912 values (83%) of 'Mysis mixta' (4912 fewer NA)
#>             changed 5,844 values (99%) of 'Stone' (5844 fewer NA)
#>             changed 5,759 values (98%) of 'Crangon crangon' (5759 fewer NA)
#>             changed 5,631 values (96%) of 'Gammarus sp.' (5631 fewer NA)
#>             changed 5,794 values (98%) of 'Priapulida' (5794 fewer NA)
#>             changed 5,808 values (99%) of 'Priapulus caudatus' (5808 fewer NA)
#>             changed 5,748 values (98%) of 'Gasterosteus aculeatus' (5748 fewer NA)
#>             changed 5,440 values (92%) of 'Pisces' (5440 fewer NA)
#>             changed 4,942 values (84%) of 'Saduria entomon' (4942 fewer NA)
#>             changed 5,784 values (98%) of 'Neomysis integer' (5784 fewer NA)
#>             changed 5,589 values (95%) of 'Clupea harengus' (5589 fewer NA)
#>             changed 5,600 values (95%) of 'Monoporeia affinis' (5600 fewer NA)
#>             changed 5,877 values (>99%) of 'scales' (5877 fewer NA)
#>             changed 5,888 values (>99%) of 'Waste' (5888 fewer NA)
#>             changed 5,629 values (96%) of 'Gobiidae' (5629 fewer NA)
#>             changed 5,331 values (91%) of 'Pontoporeia femorata' (5331 fewer NA)
#>             changed 5,530 values (94%) of 'remains' (5530 fewer NA)
#>             changed 5,858 values (99%) of 'Crustacea' (5858 fewer NA)
#>             changed 5,881 values (>99%) of 'Mysidae' (5881 fewer NA)
#>             changed 5,123 values (87%) of 'Limecola balthica' (5123 fewer NA)
#>             changed 5,859 values (99%) of 'Bivalvia' (5859 fewer NA)
#>             changed 5,888 values (>99%) of 'Halicryptus' (5888 fewer NA)
#>             changed 5,886 values (>99%) of 'Zoarces viviparus' (5886 fewer NA)
#>             changed 5,886 values (>99%) of 'Platichthys flesus' (5886 fewer NA)
#>             changed 5,888 values (>99%) of 'digestive tract' (5888 fewer NA)
#>             changed 5,887 values (>99%) of 'Wood' (5887 fewer NA)
#>             changed 5,888 values (>99%) of 'Phyllodocida ' (5888 fewer NA)
#>             changed 5,861 values (>99%) of 'Polychaeta' (5861 fewer NA)
#>             changed 5,885 values (>99%) of 'Sand' (5885 fewer NA)
#>             changed 5,746 values (98%) of 'Mytilus sp.' (5746 fewer NA)
#>             changed 5,849 values (99%) of 'Amphipoda' (5849 fewer NA)
#>             changed 5,888 values (>99%) of 'limecola balthica' (5888 fewer NA)
#>             changed 5,847 values (99%) of 'Algae' (5847 fewer NA)
#>             changed 5,888 values (>99%) of 'Pungitius pungitius' (5888 fewer NA)
#>             changed 5,854 values (99%) of 'Scoloplos armiger' (5854 fewer NA)
#>             changed 5,857 values (99%) of 'Gadus morhua' (5857 fewer NA)
#>             changed 5,872 values (>99%) of 'priapulida' (5872 fewer NA)
#>             changed 5,888 values (>99%) of 'Idotea sp.' (5888 fewer NA)
#>             changed 5,878 values (>99%) of 'Enchelyopus cimbrius' (5878 fewer NA)
#>             changed 5,888 values (>99%) of 'Pleuronectidae' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Cumacea' (5888 fewer NA)
#>             changed 5,887 values (>99%) of 'plastic' (5887 fewer NA)
#>             changed 5,831 values (99%) of 'stone' (5831 fewer NA)
#>             changed 5,885 values (>99%) of 'Crangon' (5885 fewer NA)
#>             changed 5,888 values (>99%) of 'sprattus sprattus' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Aglae' (5888 fewer NA)
#>             changed 5,675 values (96%) of 'Macoma balthica' (5675 fewer NA)
#>             changed 5,888 values (>99%) of 'Carbon' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Gasterosteidae' (5888 fewer NA)
#>             changed 5,863 values (>99%) of 'Mysida' (5863 fewer NA)
#>             changed 5,888 values (>99%) of 'gobiidae' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Gobius niger' (5888 fewer NA)
#>             changed 5,887 values (>99%) of 'Palaemon sp.' (5887 fewer NA)
#>             changed 5,886 values (>99%) of 'Mytilus sp' (5886 fewer NA)
#>             changed 5,887 values (>99%) of 'Scales' (5887 fewer NA)
#>             changed 5,886 values (>99%) of 'Ammodytidae' (5886 fewer NA)
#>             changed 5,888 values (>99%) of 'Pectinaria sp.' (5888 fewer NA)
#>             changed 5,879 values (>99%) of 'sand' (5879 fewer NA)
#>             changed 5,774 values (98%) of 'Pontoporeiidae' (5774 fewer NA)
#>             changed 5,887 values (>99%) of 'Mucus' (5887 fewer NA)
#>             changed 5,888 values (>99%) of 'Pontoporeia femotara' (5888 fewer NA)
#>             changed 5,881 values (>99%) of 'Remains' (5881 fewer NA)
#>             changed 5,887 values (>99%) of 'mucus' (5887 fewer NA)
#>             changed 5,888 values (>99%) of 'Priapulus' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'carbon' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'wood' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'halicryptus spinulosus' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'pisces' (5888 fewer NA)
#>             changed 5,874 values (>99%) of 'Mya arenaria' (5874 fewer NA)
#>             changed 5,888 values (>99%) of 'Gastrosacus' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Nephtys ciliata' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Litter/plastics' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'clupeidae' (5888 fewer NA)
#>             changed 5,877 values (>99%) of 'Pontoporeidae' (5877 fewer NA)
#>             changed 5,887 values (>99%) of 'Decapoda' (5887 fewer NA)
#>             changed 5,874 values (>99%) of 'Praunus flexuosus' (5874 fewer NA)
#>             changed 5,888 values (>99%) of 'Neogobius melanostomus' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Plastics' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Agonus cataphractus' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'clupea harengus' (5888 fewer NA)
#>             changed 5,885 values (>99%) of 'Copepoda' (5885 fewer NA)
#>             changed 5,873 values (>99%) of 'Halicryptus spinolusus' (5873 fewer NA)
#>             changed 5,888 values (>99%) of 'Prapulida' (5888 fewer NA)
#>             changed 5,722 values (97%) of 'Mytilus edulis' (5722 fewer NA)
#>             changed 5,888 values (>99%) of 'Hydrobia sp.' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Myoxocephalus scorpius' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Idotea balthica' (5888 fewer NA)
#>             changed 5,888 values (>99%) of 'Caridea' (5888 fewer NA)
  
# There is now a NA column. But it doesn't matter really, it's just the empty stomachs but these will be empty anyway because all other columns are empty!
str(d_wide)
#> tibble [5,889 × 95] (S3: tbl_df/tbl/data.frame)
#>  $ pred_id                 : chr [1:5889] "2015_4_COD_1" "2015_4_COD_101" "2015_4_COD_103" "2015_4_COD_104" ...
#>  $ diastylis_rathkei       : num [1:5889] 0.03 0.06 0.14 0 0 ...
#>  $ halicryptus_spinulosus  : num [1:5889] 0 0.07 0.28 0.01 0 0 0 0 0.02 0 ...
#>  $ bylgides_sarsi          : num [1:5889] 0 0 0.03 0 0 0 0 0 0.42 0 ...
#>  $ na                      : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ clupeidae               : num [1:5889] 0 0 0 0 0 0 0 1.74 0 0 ...
#>  $ sprattus_sprattus       : num [1:5889] 0 0 0 0 0 0 0 51.1 0 0 ...
#>  $ mysis_mixta             : num [1:5889] 0 0 0 0 0 0 0 0 0.04 0 ...
#>  $ stone                   : num [1:5889] 0 0 0 0 0 0 0 0 0.02 0 ...
#>  $ crangon_crangon         : num [1:5889] 0 0 0 0 0 0 0 0 0 0.05 ...
#>  $ gammarus_sp             : num [1:5889] 0 0 0 0 0 0 0 0 0 0.04 ...
#>  $ priapulida              : num [1:5889] 0 0 0 0 0 0 0 0 0 0.09 ...
#>  $ priapulus_caudatus      : num [1:5889] 0 0 0 0 0 0 0 0 0 0.14 ...
#>  $ gasterosteus_aculeatus  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pisces                  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ saduria_entomon         : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ neomysis_integer        : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ clupea_harengus         : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ monoporeia_affinis      : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ scales                  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ waste                   : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ gobiidae                : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pontoporeia_femorata    : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ remains                 : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ crustacea               : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ mysidae                 : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ limecola_balthica       : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ bivalvia                : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ halicryptus             : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ zoarces_viviparus       : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ platichthys_flesus      : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ digestive_tract         : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ wood                    : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ phyllodocida            : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ polychaeta              : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ sand                    : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ mytilus_sp              : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ amphipoda               : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ limecola_balthica_2     : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ algae                   : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pungitius_pungitius     : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ scoloplos_armiger       : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ gadus_morhua            : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ priapulida_2            : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ idotea_sp               : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ enchelyopus_cimbrius    : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pleuronectidae          : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ cumacea                 : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ plastic                 : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ stone_2                 : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ crangon                 : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ sprattus_sprattus_2     : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ aglae                   : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ macoma_balthica         : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ carbon                  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ gasterosteidae          : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ mysida                  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ gobiidae_2              : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ gobius_niger            : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ palaemon_sp             : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ mytilus_sp_2            : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ scales_2                : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ ammodytidae             : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pectinaria_sp           : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ sand_2                  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pontoporeiidae          : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ mucus                   : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pontoporeia_femotara    : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ remains_2               : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ mucus_2                 : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ priapulus               : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ carbon_2                : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ wood_2                  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ halicryptus_spinulosus_2: num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pisces_2                : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ mya_arenaria            : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ gastrosacus             : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ nephtys_ciliata         : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ litter_plastics         : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ clupeidae_2             : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ pontoporeidae           : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ decapoda                : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ praunus_flexuosus       : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ neogobius_melanostomus  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ plastics                : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ agonus_cataphractus     : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ clupea_harengus_2       : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ copepoda                : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ halicryptus_spinolusus  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ prapulida               : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ mytilus_edulis          : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ hydrobia_sp             : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ myoxocephalus_scorpius  : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ idotea_balthica         : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...
#>  $ caridea                 : num [1:5889] 0 0 0 0 0 0 0 0 0 0 ...

d_wide %>%
  mutate(sum = rowSums(across(where(is.numeric)))) %>% 
  filter(sum == 0) %>% 
  distinct(na)
#> mutate: new variable 'sum' (double) with 2,166 unique values and 0% NA
#> filter: removed 4,364 rows (74%), 1,525 rows remaining
#> distinct: removed 1,524 rows (>99%), one row remaining
#> # A tibble: 1 × 1
#>      na
#>   <dbl>
#> 1     0

d_wide <- d_wide %>% dplyr::select(-na)

# Now make some calculations and aggregate to some taxonomic level. Since all columns are assigned to some higher level group (or the same group), the sum of these is the total stomach content. Note that I have one group for unidentified clupeids, but also sprat and herring. So if I want the total of some aggregated group, then I need to add all the sub-groups.

sort(colnames(d_wide))
#>  [1] "aglae"                    "agonus_cataphractus"     
#>  [3] "algae"                    "ammodytidae"             
#>  [5] "amphipoda"                "bivalvia"                
#>  [7] "bylgides_sarsi"           "carbon"                  
#>  [9] "carbon_2"                 "caridea"                 
#> [11] "clupea_harengus"          "clupea_harengus_2"       
#> [13] "clupeidae"                "clupeidae_2"             
#> [15] "copepoda"                 "crangon"                 
#> [17] "crangon_crangon"          "crustacea"               
#> [19] "cumacea"                  "decapoda"                
#> [21] "diastylis_rathkei"        "digestive_tract"         
#> [23] "enchelyopus_cimbrius"     "gadus_morhua"            
#> [25] "gammarus_sp"              "gasterosteidae"          
#> [27] "gasterosteus_aculeatus"   "gastrosacus"             
#> [29] "gobiidae"                 "gobiidae_2"              
#> [31] "gobius_niger"             "halicryptus"             
#> [33] "halicryptus_spinolusus"   "halicryptus_spinulosus"  
#> [35] "halicryptus_spinulosus_2" "hydrobia_sp"             
#> [37] "idotea_balthica"          "idotea_sp"               
#> [39] "limecola_balthica"        "limecola_balthica_2"     
#> [41] "litter_plastics"          "macoma_balthica"         
#> [43] "monoporeia_affinis"       "mucus"                   
#> [45] "mucus_2"                  "mya_arenaria"            
#> [47] "myoxocephalus_scorpius"   "mysida"                  
#> [49] "mysidae"                  "mysis_mixta"             
#> [51] "mytilus_edulis"           "mytilus_sp"              
#> [53] "mytilus_sp_2"             "neogobius_melanostomus"  
#> [55] "neomysis_integer"         "nephtys_ciliata"         
#> [57] "palaemon_sp"              "pectinaria_sp"           
#> [59] "phyllodocida"             "pisces"                  
#> [61] "pisces_2"                 "plastic"                 
#> [63] "plastics"                 "platichthys_flesus"      
#> [65] "pleuronectidae"           "polychaeta"              
#> [67] "pontoporeia_femorata"     "pontoporeia_femotara"    
#> [69] "pontoporeidae"            "pontoporeiidae"          
#> [71] "prapulida"                "praunus_flexuosus"       
#> [73] "pred_id"                  "priapulida"              
#> [75] "priapulida_2"             "priapulus"               
#> [77] "priapulus_caudatus"       "pungitius_pungitius"     
#> [79] "remains"                  "remains_2"               
#> [81] "saduria_entomon"          "sand"                    
#> [83] "sand_2"                   "scales"                  
#> [85] "scales_2"                 "scoloplos_armiger"       
#> [87] "sprattus_sprattus"        "sprattus_sprattus_2"     
#> [89] "stone"                    "stone_2"                 
#> [91] "waste"                    "wood"                    
#> [93] "wood_2"                   "zoarces_viviparus"

d_wide2 <- d_wide %>% 
  mutate(amphipoda_tot = gammarus_sp + monoporeia_affinis + 
             amphipoda,
         bivalvia_tot =  bivalvia + mytilus_sp + mytilus_sp_2 + mya_arenaria + macoma_balthica + 
             mytilus_edulis + limecola_balthica + limecola_balthica_2,
         clupeidae_tot = clupeidae + clupeidae_2,
         clupea_harengus_tot = clupea_harengus + clupea_harengus_2,
         gadus_morhua_tot = gadus_morhua,
         gobiidae_tot = gobiidae + gobiidae_2 + gobius_niger + neogobius_melanostomus,
         mysidae_tot = mysidae + neomysis_integer + mysis_mixta + mysida + gastrosacus,
         non_bio_tot = stone + stone_2 + plastic + plastics + sand + wood + carbon + stone_2 + carbon_2 + wood_2 + 
             litter_plastics + sand_2,
         other_crustacea_tot = pontoporeia_femorata + pontoporeia_femotara + crangon + 
             crangon_crangon + idotea_balthica + cumacea + idotea_sp +
             praunus_flexuosus + crustacea + diastylis_rathkei + palaemon_sp + caridea +
             copepoda + pontoporeiidae + decapoda + 
             pontoporeidae, 
         other_tot = halicryptus_spinulosus + halicryptus_spinulosus_2 + priapulus_caudatus + algae + aglae + 
             waste + remains + remains_2 + hydrobia_sp + 
             priapulida + halicryptus + digestive_tract + mucus + mucus_2 + remains_2 + 
             halicryptus_spinolusus + priapulida_2 + prapulida + priapulus,
         other_pisces_tot = pisces + pisces_2 + 
             enchelyopus_cimbrius +
             gasterosteus_aculeatus + scales + scales_2 +
             pungitius_pungitius + zoarces_viviparus +
             ammodytidae +
             pleuronectidae + gasterosteidae +
             agonus_cataphractus + myoxocephalus_scorpius,
         platichthys_flesus_tot = platichthys_flesus,
         polychaeta_tot = bylgides_sarsi + scoloplos_armiger +
             phyllodocida + polychaeta + pectinaria_sp + nephtys_ciliata,
         saduria_entomon_tot = saduria_entomon,
         sprattus_sprattus_tot = sprattus_sprattus + sprattus_sprattus_2
         )
#> mutate: new variable 'amphipoda_tot' (double) with 176 unique values and 0% NA
#>         new variable 'bivalvia_tot' (double) with 661 unique values and 0% NA
#>         new variable 'clupeidae_tot' (double) with 201 unique values and 0% NA
#>         new variable 'clupea_harengus_tot' (double) with 287 unique values and 0% NA
#>         new variable 'gadus_morhua_tot' (double) with 33 unique values and 0% NA
#>         new variable 'gobiidae_tot' (double) with 151 unique values and 0% NA
#>         new variable 'mysidae_tot' (double) with 298 unique values and 0% NA
#>         new variable 'non_bio_tot' (double) with 62 unique values and 0% NA
#>         new variable 'other_crustacea_tot' (double) with 470 unique values and 0% NA
#>         new variable 'other_tot' (double) with 350 unique values and 0% NA
#>         new variable 'other_pisces_tot' (double) with 235 unique values and 0% NA
#>         new variable 'platichthys_flesus_tot' (double) with 4 unique values and 0% NA
#>         new variable 'polychaeta_tot' (double) with 105 unique values and 0% NA
#>         new variable 'saduria_entomon_tot' (double) with 431 unique values and 0% NA
#>         new variable 'sprattus_sprattus_tot' (double) with 518 unique values and 0% NA

# Select only columns aggregated columns (ending with _tot) (all columns (prey) are represented there)
colnames(d_wide2)
#>   [1] "pred_id"                  "diastylis_rathkei"       
#>   [3] "halicryptus_spinulosus"   "bylgides_sarsi"          
#>   [5] "clupeidae"                "sprattus_sprattus"       
#>   [7] "mysis_mixta"              "stone"                   
#>   [9] "crangon_crangon"          "gammarus_sp"             
#>  [11] "priapulida"               "priapulus_caudatus"      
#>  [13] "gasterosteus_aculeatus"   "pisces"                  
#>  [15] "saduria_entomon"          "neomysis_integer"        
#>  [17] "clupea_harengus"          "monoporeia_affinis"      
#>  [19] "scales"                   "waste"                   
#>  [21] "gobiidae"                 "pontoporeia_femorata"    
#>  [23] "remains"                  "crustacea"               
#>  [25] "mysidae"                  "limecola_balthica"       
#>  [27] "bivalvia"                 "halicryptus"             
#>  [29] "zoarces_viviparus"        "platichthys_flesus"      
#>  [31] "digestive_tract"          "wood"                    
#>  [33] "phyllodocida"             "polychaeta"              
#>  [35] "sand"                     "mytilus_sp"              
#>  [37] "amphipoda"                "limecola_balthica_2"     
#>  [39] "algae"                    "pungitius_pungitius"     
#>  [41] "scoloplos_armiger"        "gadus_morhua"            
#>  [43] "priapulida_2"             "idotea_sp"               
#>  [45] "enchelyopus_cimbrius"     "pleuronectidae"          
#>  [47] "cumacea"                  "plastic"                 
#>  [49] "stone_2"                  "crangon"                 
#>  [51] "sprattus_sprattus_2"      "aglae"                   
#>  [53] "macoma_balthica"          "carbon"                  
#>  [55] "gasterosteidae"           "mysida"                  
#>  [57] "gobiidae_2"               "gobius_niger"            
#>  [59] "palaemon_sp"              "mytilus_sp_2"            
#>  [61] "scales_2"                 "ammodytidae"             
#>  [63] "pectinaria_sp"            "sand_2"                  
#>  [65] "pontoporeiidae"           "mucus"                   
#>  [67] "pontoporeia_femotara"     "remains_2"               
#>  [69] "mucus_2"                  "priapulus"               
#>  [71] "carbon_2"                 "wood_2"                  
#>  [73] "halicryptus_spinulosus_2" "pisces_2"                
#>  [75] "mya_arenaria"             "gastrosacus"             
#>  [77] "nephtys_ciliata"          "litter_plastics"         
#>  [79] "clupeidae_2"              "pontoporeidae"           
#>  [81] "decapoda"                 "praunus_flexuosus"       
#>  [83] "neogobius_melanostomus"   "plastics"                
#>  [85] "agonus_cataphractus"      "clupea_harengus_2"       
#>  [87] "copepoda"                 "halicryptus_spinolusus"  
#>  [89] "prapulida"                "mytilus_edulis"          
#>  [91] "hydrobia_sp"              "myoxocephalus_scorpius"  
#>  [93] "idotea_balthica"          "caridea"                 
#>  [95] "amphipoda_tot"            "bivalvia_tot"            
#>  [97] "clupeidae_tot"            "clupea_harengus_tot"     
#>  [99] "gadus_morhua_tot"         "gobiidae_tot"            
#> [101] "mysidae_tot"              "non_bio_tot"             
#> [103] "other_crustacea_tot"      "other_tot"               
#> [105] "other_pisces_tot"         "platichthys_flesus_tot"  
#> [107] "polychaeta_tot"           "saduria_entomon_tot"     
#> [109] "sprattus_sprattus_tot"

d_wide3 <- d_wide2 %>%
  dplyr::select(pred_id, ends_with("_tot"))

# Add back in other information about the predator ID
d_sel <- d %>%
  dplyr::select(predator_latin_name, species, pred_weight_g, pred_length_cm,
                year, quarter, month, day, ices_rect, subdiv, haul_id,
                X, Y, lat, lon, pred_id, depth, pred_weight_source, cruise,
                fle_kg_km2, lcod_kg_km2, scod_kg_km2
                ) %>% 
  distinct(pred_id, .keep_all = TRUE)
#> distinct: removed 51,802 rows (90%), 5,928 rows remaining

d_wide3 <- left_join(d_wide3, d_sel) %>% filter(year > 1992)
#> Joining, by = "pred_id"
#> left_join: added 21 columns (predator_latin_name, species, pred_weight_g, pred_length_cm, year, …)
#>            > rows only in x       0
#>            > rows only in y  (   39)
#>            > matched rows     5,889
#>            >                 =======
#>            > rows total       5,889
#> filter: no rows removed

# Make separate data frames for cod and flounder. They are wide so that we can easily add columns when calculating aggregate response variables (sums across prey groups)
d_wide_cod <- d_wide3 %>% filter(grepl("COD", pred_id))
#> filter: removed 2,579 rows (44%), 3,310 rows remaining
d_wide_fle <- d_wide3 %>% filter(grepl("FLE", pred_id))
#> filter: removed 3,310 rows (56%), 2,579 rows remaining

Find which prey are shared for cod and flounder

long_cod <- d_wide_cod %>%
  pivot_longer(cols = ends_with("_tot"), names_to = "prey_group", values_to = "tot_prey_weight")
#> pivot_longer: reorganized (amphipoda_tot, bivalvia_tot, clupeidae_tot, clupea_harengus_tot, gadus_morhua_tot, …) into (prey_group, tot_prey_weight) [was 3310x37, now 49650x24]

long_fle <- d_wide_fle %>%
  pivot_longer(cols = ends_with("_tot"), names_to = "prey_group", values_to = "tot_prey_weight")
#> pivot_longer: reorganized (amphipoda_tot, bivalvia_tot, clupeidae_tot, clupea_harengus_tot, gadus_morhua_tot, …) into (prey_group, tot_prey_weight) [was 2579x37, now 38685x24]
s_cod_important_prey <- long_cod %>%
  filter(pred_length_cm <= 25) %>% 
  group_by(prey_group, year, quarter) %>%
  summarise(prey_group_tot = sum(tot_prey_weight)) %>% 
  ungroup() %>% 
  group_by(year, quarter) %>%
  mutate(percent_by_group = 100 * (prey_group_tot / sum(prey_group_tot))) %>% 
  ungroup()
#> filter: removed 32,310 rows (65%), 17,340 rows remaining
#> group_by: 3 grouping variables (prey_group, year, quarter)
#> summarise: now 120 rows and 4 columns, 2 group variables remaining (prey_group, year)
#> ungroup: no grouping variables
#> group_by: 2 grouping variables (year, quarter)
#> mutate (grouped): new variable 'percent_by_group' (double) with 82 unique values and 0% NA
#> ungroup: no grouping variables

l_cod_important_prey <- long_cod %>%
  filter(pred_length_cm > 25) %>% 
  group_by(prey_group, year, quarter) %>%
  summarise(prey_group_tot = sum(tot_prey_weight)) %>% 
  ungroup() %>% 
  group_by(year, quarter) %>%
  mutate(percent_by_group = 100 * (prey_group_tot / sum(prey_group_tot))) %>% 
  ungroup()
#> filter: removed 17,340 rows (35%), 32,310 rows remaining
#> group_by: 3 grouping variables (prey_group, year, quarter)
#> summarise: now 120 rows and 4 columns, 2 group variables remaining (prey_group, year)
#> ungroup: no grouping variables
#> group_by: 2 grouping variables (year, quarter)
#> mutate (grouped): new variable 'percent_by_group' (double) with 113 unique values and 0% NA
#> ungroup: no grouping variables

fle_important_prey <- long_fle %>%
  group_by(prey_group, year, quarter) %>%
  summarise(prey_group_tot = sum(tot_prey_weight)) %>% 
  ungroup() %>% 
  group_by(year, quarter) %>%
  mutate(percent_by_group = 100 * (prey_group_tot / sum(prey_group_tot))) %>% 
  ungroup() %>% 
  mutate(predator = "flounder")
#> group_by: 3 grouping variables (prey_group, year, quarter)
#> summarise: now 120 rows and 4 columns, 2 group variables remaining (prey_group, year)
#> ungroup: no grouping variables
#> group_by: 2 grouping variables (year, quarter)
#> mutate (grouped): new variable 'percent_by_group' (double) with 91 unique values and 0% NA
#> ungroup: no grouping variables
#> mutate: new variable 'predator' (character) with one unique value and 0% NA

s_cod_important_prey %>% 
  ggplot(aes(x = reorder(prey_group, desc(percent_by_group)), y = percent_by_group)) +
  geom_bar(stat = "identity", position = position_dodge()) + 
  theme_classic(base_size = 16) + 
  facet_grid(quarter~year) +
  theme(axis.text.x = element_text(angle = 90, size = 6)) +
  labs(x = "Prey group", y = "Percent") + 
  NULL


s_cod_important_prey %>% 
  ggplot(aes(x = reorder(prey_group, desc(percent_by_group)), y = percent_by_group)) +
  geom_bar(stat = "identity", position = position_dodge()) + 
  theme_classic(base_size = 16) + 
  facet_grid(quarter~year) +
  theme(axis.text.x = element_text(angle = 90, size = 6)) +
  labs(x = "Prey group", y = "Percent") + 
  NULL


fle_important_prey %>% 
  ggplot(aes(x = reorder(prey_group, desc(percent_by_group)), y = percent_by_group)) +
  geom_bar(stat = "identity", position = position_dodge()) + 
  theme_classic(base_size = 16) + 
  facet_grid(quarter~year) +
  theme(axis.text.x = element_text(angle = 90, size = 6)) +
  labs(x = "Prey group", y = "Percent") + 
  NULL


# Aggregate all data
s_cod_important_prey2 <- long_cod %>%
  filter(pred_length_cm <= 25) %>% 
  group_by(prey_group, quarter) %>%
  summarise(sum_tot_prey_weight = sum(tot_prey_weight)) %>% 
  ungroup() %>% 
  group_by(quarter) %>%
  mutate(percent_by_group = 100 * (sum_tot_prey_weight / sum(sum_tot_prey_weight))) %>% 
  ungroup() %>% 
  mutate(predator = "Cod <= 25 cm")
#> filter: removed 32,310 rows (65%), 17,340 rows remaining
#> group_by: 2 grouping variables (prey_group, quarter)
#> summarise: now 30 rows and 3 columns, one group variable remaining (prey_group)
#> ungroup: no grouping variables
#> group_by: one grouping variable (quarter)
#> mutate (grouped): new variable 'percent_by_group' (double) with 26 unique values and 0% NA
#> ungroup: no grouping variables
#> mutate: new variable 'predator' (character) with one unique value and 0% NA

l_cod_important_prey2 <- long_cod %>%
  filter(pred_length_cm > 25) %>% 
  group_by(prey_group, quarter) %>%
  summarise(sum_tot_prey_weight = sum(tot_prey_weight)) %>% 
  ungroup() %>% 
  group_by(quarter) %>%
  mutate(percent_by_group = 100 * (sum_tot_prey_weight / sum(sum_tot_prey_weight))) %>% 
  ungroup() %>% 
  mutate(predator = "Cod > 25 cm")
#> filter: removed 17,340 rows (35%), 32,310 rows remaining
#> group_by: 2 grouping variables (prey_group, quarter)
#> summarise: now 30 rows and 3 columns, one group variable remaining (prey_group)
#> ungroup: no grouping variables
#> group_by: one grouping variable (quarter)
#> mutate (grouped): new variable 'percent_by_group' (double) with 30 unique values and 0% NA
#> ungroup: no grouping variables
#> mutate: new variable 'predator' (character) with one unique value and 0% NA

fle_important_prey2 <- long_fle %>%
  group_by(prey_group, quarter) %>%
  summarise(sum_tot_prey_weight = sum(tot_prey_weight)) %>% 
  ungroup() %>% 
  group_by(quarter) %>%
  mutate(percent_by_group = 100 * (sum_tot_prey_weight / sum(sum_tot_prey_weight))) %>% 
  ungroup() %>% 
  mutate(predator = "Flounder")
#> group_by: 2 grouping variables (prey_group, quarter)
#> summarise: now 30 rows and 3 columns, one group variable remaining (prey_group)
#> ungroup: no grouping variables
#> group_by: one grouping variable (quarter)
#> mutate (grouped): new variable 'percent_by_group' (double) with 27 unique values and 0% NA
#> ungroup: no grouping variables
#> mutate: new variable 'predator' (character) with one unique value and 0% NA
  
plotdat <- bind_rows(s_cod_important_prey2, l_cod_important_prey2, fle_important_prey2)

plotdat %>% 
  ggplot(aes(x = reorder(prey_group, desc(percent_by_group)), y = percent_by_group)) +
  geom_bar(stat = "identity", position = position_dodge()) + 
  theme_classic(base_size = 16) + 
  theme(axis.text.x = element_text(angle = 90)) +
  labs(x = "Prey group", y = "Percent") + 
  facet_grid(quarter~predator) +
  theme(legend.text = element_text(size = 4)) +
  NULL


plotdat %>% arrange(desc(percent_by_group)) %>% distinct(prey_group) %>% as.data.frame()
#> distinct: removed 75 rows (83%), 15 rows remaining
#>                prey_group
#> 1            bivalvia_tot
#> 2             mysidae_tot
#> 3     clupea_harengus_tot
#> 4   sprattus_sprattus_tot
#> 5     saduria_entomon_tot
#> 6     other_crustacea_tot
#> 7            gobiidae_tot
#> 8               other_tot
#> 9        other_pisces_tot
#> 10       gadus_morhua_tot
#> 11         polychaeta_tot
#> 12          clupeidae_tot
#> 13 platichthys_flesus_tot
#> 14          amphipoda_tot
#> 15            non_bio_tot

plotdat %>% 
  mutate(prey_group = ifelse(prey_group == "bivalvia_tot", "Bivalvia", prey_group),
         prey_group = ifelse(prey_group == "mysidae_tot", "Mysidae", prey_group),
         prey_group = ifelse(prey_group == "clupea_harengus_tot", "Clupea harengus", prey_group),
         prey_group = ifelse(prey_group == "sprattus_sprattus_tot", "Sprattus sprattus", prey_group),
         prey_group = ifelse(prey_group == "saduria_entomon_tot", "Saduria entomon", prey_group),
         prey_group = ifelse(prey_group == "other_crustacea_tot", "Other crustacea", prey_group),
         prey_group = ifelse(prey_group == "gobiidae_tot", "Gobiidae", prey_group),
         prey_group = ifelse(prey_group == "other_tot", "Other", prey_group),
         prey_group = ifelse(prey_group == "other_pisces_tot", "Other pisces", prey_group),
         prey_group = ifelse(prey_group == "gadus_morhua_tot", "Gadus morhua", prey_group),
         prey_group = ifelse(prey_group == "polychaeta_tot", "Polychaeta", prey_group),
         prey_group = ifelse(prey_group == "clupeidae_tot", "Clupeidae", prey_group),
         prey_group = ifelse(prey_group == "platichthys_flesus_tot", "platichthys_flesus", prey_group),
         prey_group = ifelse(prey_group == "amphipoda_tot", "Amphipoda", prey_group),
         prey_group = ifelse(prey_group == "non_bio_tot", "Non-bio", prey_group)) %>% 
  ggplot(aes(x = reorder(prey_group, desc(percent_by_group)), y = percent_by_group,
             fill = predator)) +
  geom_bar(stat = "identity", position = position_dodge()) + 
  theme(axis.text.x = element_text(angle = 90),
        legend.position = c(0.8, 0.8)) +
  labs(x = "Prey group", y = "Percent", fill = "Predator") + 
  NULL
#> mutate: changed 90 values (100%) of 'prey_group' (0 new NA)


ggsave("figures/supp/bar_diet_comp.pdf", width = 17, height = 17, units = "cm")
colourCount <- length(unique(plotdat$prey_group))
getPalette <- colorRampPalette(brewer.pal(12, "Paired"))
pal <- getPalette(colourCount)

plotdat$pred_new <- factor(plotdat$predator, levels = c("Flounder", "Cod <= 25 cm", "Cod > 25 cm")) 

plotdat %>% 
  mutate(prey_group = ifelse(prey_group == "bivalvia_tot", "Bivalvia", prey_group),
         prey_group = ifelse(prey_group == "mysidae_tot", "Mysidae", prey_group),
         prey_group = ifelse(prey_group == "gadus_morhua_tot", "Gadus morhua", prey_group),
         prey_group = ifelse(prey_group == "saduria_entomon_tot", "Saduria entomon", prey_group),
         prey_group = ifelse(prey_group == "gobiidae_tot", "Gobiidae", prey_group),
         prey_group = ifelse(prey_group == "other_crustacea_tot", "Other crustacea", prey_group),
         prey_group = ifelse(prey_group == "polychaeta_tot", "Polychaeta", prey_group),
         prey_group = ifelse(prey_group == "platichthys_flesus_tot", "Platichthys flesus", prey_group),
         prey_group = ifelse(prey_group == "sprattus_sprattus_tot", "Sprattus sprattus", prey_group),
         prey_group = ifelse(prey_group == "other_pisces_tot", "Other pisces", prey_group),
         prey_group = ifelse(prey_group == "clupeidae_tot", "Clupeidae", prey_group),
         prey_group = ifelse(prey_group == "clupea_harengus_tot", "Clupea harengus", prey_group),
         prey_group = ifelse(prey_group == "other_tot", "Other", prey_group),
         prey_group = ifelse(prey_group == "amphipoda_tot", "Amphipoda", prey_group),
         prey_group = ifelse(prey_group == "non_bio_tot", "Non-bio", prey_group)) %>% 
  ggplot(aes(x = "" , y = percent_by_group, fill = fct_inorder(prey_group))) +
  facet_wrap(~pred_new) +
  labs(x = "", y = "") +
  geom_col(width = 1, color = NA, alpha = 0.8) +
  coord_polar(theta = "y") +
  scale_fill_manual(values = pal) +  
  guides(fill = guide_legend(title.position = "top", title = "Prey group")) +
  theme_plot() + 
  theme(legend.position = "bottom",
        axis.text = element_blank(),
        legend.text = element_text(size = 8),
        axis.ticks = element_blank(),
        panel.grid  = element_blank())
#> mutate: changed 90 values (100%) of 'prey_group' (0 new NA)


ggsave("figures/supp/total_pie.pdf", width = 17, height = 17, units = "cm")
# Prop from prey by size class, years and quarters pooled

long_cod %>% filter(pred_length_cm < 6) %>% arrange(desc(pred_length_cm)) %>% as.data.frame()
#> filter: removed 49,320 rows (99%), 330 rows remaining
#>            pred_id predator_latin_name species pred_weight_g pred_length_cm
#> 1    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 2    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 3    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 4    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 5    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 6    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 7    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 8    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 9    2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 10   2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 11   2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 12   2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 13   2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 14   2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 15   2015_4_COD_11        Gadus morhua     Cod          1.00              5
#> 16  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 17  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 18  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 19  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 20  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 21  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 22  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 23  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 24  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 25  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 26  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 27  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 28  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 29  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 30  2015_4_COD_410        Gadus morhua     Cod          0.90              5
#> 31  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 32  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 33  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 34  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 35  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 36  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 37  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 38  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 39  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 40  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 41  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 42  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 43  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 44  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 45  2016_1_COD_656        Gadus morhua     Cod          1.25              5
#> 46  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 47  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 48  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 49  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 50  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 51  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 52  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 53  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 54  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 55  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 56  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 57  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 58  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 59  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 60  2016_1_COD_657        Gadus morhua     Cod          1.25              5
#> 61  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 62  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 63  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 64  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 65  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 66  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 67  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 68  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 69  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 70  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 71  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 72  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 73  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 74  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 75  2017_1_COD_505        Gadus morhua     Cod          1.00              5
#> 76  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 77  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 78  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 79  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 80  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 81  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 82  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 83  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 84  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 85  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 86  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 87  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 88  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 89  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 90  2017_1_COD_586        Gadus morhua     Cod          1.00              5
#> 91  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 92  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 93  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 94  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 95  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 96  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 97  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 98  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 99  2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 100 2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 101 2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 102 2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 103 2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 104 2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 105 2017_4_COD_101        Gadus morhua     Cod          1.00              5
#> 106 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 107 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 108 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 109 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 110 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 111 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 112 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 113 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 114 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 115 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 116 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 117 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 118 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 119 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 120 2017_4_COD_129        Gadus morhua     Cod          1.00              5
#> 121  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 122  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 123  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 124  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 125  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 126  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 127  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 128  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 129  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 130  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 131  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 132  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 133  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 134  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 135  2017_4_COD_71        Gadus morhua     Cod          1.00              5
#> 136 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 137 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 138 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 139 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 140 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 141 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 142 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 143 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 144 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 145 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 146 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 147 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 148 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 149 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 150 2018_1_COD_606        Gadus morhua     Cod          1.36              5
#> 151 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 152 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 153 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 154 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 155 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 156 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 157 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 158 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 159 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 160 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 161 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 162 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 163 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 164 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 165 2019_4_COD_109        Gadus morhua     Cod          1.33              5
#> 166 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 167 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 168 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 169 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 170 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 171 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 172 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 173 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 174 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 175 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 176 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 177 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 178 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 179 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 180 2019_4_COD_144        Gadus morhua     Cod          1.29              5
#> 181 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 182 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 183 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 184 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 185 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 186 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 187 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 188 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 189 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 190 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 191 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 192 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 193 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 194 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 195 2019_4_COD_176        Gadus morhua     Cod          1.22              5
#> 196 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 197 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 198 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 199 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 200 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 201 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 202 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 203 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 204 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 205 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 206 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 207 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 208 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 209 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 210 2019_4_COD_202        Gadus morhua     Cod          1.48              5
#> 211 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 212 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 213 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 214 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 215 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 216 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 217 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 218 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 219 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 220 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 221 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 222 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 223 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 224 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 225 2019_4_COD_278        Gadus morhua     Cod          1.17              5
#> 226 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 227 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 228 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 229 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 230 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 231 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 232 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 233 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 234 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 235 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 236 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 237 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 238 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 239 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 240 2019_4_COD_300        Gadus morhua     Cod          0.98              5
#> 241 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 242 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 243 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 244 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 245 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 246 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 247 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 248 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 249 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 250 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 251 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 252 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 253 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 254 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 255 2019_4_COD_326        Gadus morhua     Cod          0.84              5
#> 256 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 257 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 258 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 259 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 260 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 261 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 262 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 263 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 264 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 265 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 266 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 267 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 268 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 269 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 270 2019_4_COD_346        Gadus morhua     Cod          1.25              5
#> 271  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 272  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 273  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 274  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 275  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 276  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 277  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 278  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 279  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 280  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 281  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 282  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 283  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 284  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 285  2019_4_COD_53        Gadus morhua     Cod          0.88              5
#> 286  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 287  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 288  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 289  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 290  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 291  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 292  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 293  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 294  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 295  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 296  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 297  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 298  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 299  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 300  2019_4_COD_79        Gadus morhua     Cod          1.38              5
#> 301  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 302  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 303  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 304  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 305  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 306  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 307  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 308  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 309  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 310  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 311  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 312  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 313  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 314  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 315  2017_4_COD_15        Gadus morhua     Cod          1.00              4
#> 316  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 317  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 318  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 319  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 320  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 321  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 322  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 323  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 324  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 325  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 326  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 327  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 328  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 329  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#> 330  2017_4_COD_57        Gadus morhua     Cod          1.00              4
#>     year quarter month day ices_rect subdiv   haul_id        X        Y
#> 1   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 2   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 3   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 4   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 5   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 6   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 7   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 8   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 9   2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 10  2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 11  2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 12  2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 13  2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 14  2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 15  2015       4    11  20      40G4     25  2015_4_2 474.8173 6165.344
#> 16  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 17  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 18  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 19  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 20  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 21  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 22  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 23  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 24  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 25  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 26  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 27  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 28  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 29  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 30  2015       4    11  23      43G8     28 2015_4_21 728.9385 6338.581
#> 31  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 32  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 33  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 34  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 35  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 36  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 37  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 38  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 39  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 40  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 41  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 42  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 43  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 44  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 45  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 46  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 47  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 48  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 49  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 50  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 51  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 52  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 53  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 54  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 55  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 56  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 57  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 58  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 59  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 60  2016       1     2  NA      44G9     28 2016_1_55 761.9226 6422.421
#> 61  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 62  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 63  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 64  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 65  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 66  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 67  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 68  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 69  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 70  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 71  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 72  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 73  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 74  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 75  2017       1     3   3      41G8     26 2017_1_73 713.0776 6252.234
#> 76  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 77  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 78  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 79  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 80  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 81  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 82  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 83  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 84  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 85  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 86  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 87  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 88  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 89  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 90  2017       1     3   4      40G8     26 2017_1_82 729.1156 6202.880
#> 91  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 92  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 93  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 94  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 95  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 96  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 97  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 98  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 99  2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 100 2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 101 2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 102 2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 103 2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 104 2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 105 2017       4    11  NA      40G4     25  2017_4_7 489.5205 6170.849
#> 106 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 107 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 108 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 109 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 110 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 111 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 112 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 113 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 114 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 115 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 116 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 117 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 118 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 119 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 120 2017       4    11  NA      40G5     25 2017_4_10 515.6724 6183.849
#> 121 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 122 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 123 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 124 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 125 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 126 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 127 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 128 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 129 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 130 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 131 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 132 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 133 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 134 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 135 2017       4    11  NA      40G4     25  2017_4_6 474.7959 6161.635
#> 136 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 137 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 138 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 139 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 140 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 141 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 142 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 143 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 144 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 145 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 146 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 147 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 148 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 149 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 150 2018       1     3  NA      40G4     25 2018_1_62 459.1304 6171.028
#> 151 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 152 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 153 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 154 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 155 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 156 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 157 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 158 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 159 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 160 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 161 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 162 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 163 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 164 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 165 2019       4    11  NA      40G4     25 2019_4_68 460.1953 6172.873
#> 166 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 167 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 168 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 169 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 170 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 171 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 172 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 173 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 174 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 175 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 176 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 177 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 178 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 179 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 180 2019       4    11  NA      40G4     25 2019_4_69 465.4179 6170.973
#> 181 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 182 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 183 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 184 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 185 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 186 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 187 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 188 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 189 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 190 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 191 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 192 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 193 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 194 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 195 2019       4    11  NA      40G4     25 2019_4_70 468.5617 6170.950
#> 196 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 197 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 198 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 199 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 200 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 201 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 202 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 203 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 204 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 205 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 206 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 207 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 208 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 209 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 210 2019       4    11  NA      40G4     25 2019_4_71 460.1953 6172.873
#> 211 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 212 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 213 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 214 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 215 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 216 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 217 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 218 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 219 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 220 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 221 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 222 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 223 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 224 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 225 2019       4    11  NA      41G8     26 2019_4_86 715.0414 6254.191
#> 226 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 227 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 228 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 229 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 230 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 231 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 232 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 233 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 234 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 235 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 236 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 237 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 238 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 239 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 240 2019       4    11  27      41G8     26 2019_4_93 712.2339 6248.475
#> 241 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 242 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 243 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 244 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 245 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 246 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 247 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 248 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 249 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 250 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 251 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 252 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 253 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 254 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 255 2019       4    11  NA      40G5     25 2019_4_95 535.4783 6189.530
#> 256 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 257 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 258 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 259 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 260 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 261 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 262 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 263 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 264 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 265 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 266 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 267 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 268 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 269 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 270 2019       4    11  NA      40G4     25 2019_4_97 465.4179 6170.973
#> 271 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 272 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 273 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 274 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 275 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 276 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 277 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 278 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 279 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 280 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 281 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 282 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 283 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 284 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 285 2019       4    11  NA      39G4     24 2019_4_66 469.4290 6144.975
#> 286 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 287 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 288 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 289 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 290 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 291 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 292 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 293 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 294 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 295 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 296 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 297 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 298 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 299 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 300 2019       4    11  NA      40G4     25 2019_4_67 460.1783 6171.018
#> 301 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 302 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 303 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 304 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 305 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 306 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 307 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 308 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 309 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 310 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 311 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 312 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 313 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 314 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 315 2017       4    11  NA      39G4     24  2017_4_2 469.4290 6144.975
#> 316 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 317 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 318 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 319 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 320 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 321 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 322 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 323 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 324 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 325 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 326 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 327 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 328 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 329 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#> 330 2017       4    11  NA      39G4     24  2017_4_4 477.8717 6146.779
#>          lat      lon depth    pred_weight_source cruise fle_kg_km2
#> 1   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 2   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 3   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 4   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 5   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 6   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 7   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 8   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 9   55.63333 14.60000  60.2              measured   BITS   330.2812
#> 10  55.63333 14.60000  60.2              measured   BITS   330.2812
#> 11  55.63333 14.60000  60.2              measured   BITS   330.2812
#> 12  55.63333 14.60000  60.2              measured   BITS   330.2812
#> 13  55.63333 14.60000  60.2              measured   BITS   330.2812
#> 14  55.63333 14.60000  60.2              measured   BITS   330.2812
#> 15  55.63333 14.60000  60.2              measured   BITS   330.2812
#> 16  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 17  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 18  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 19  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 20  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 21  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 22  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 23  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 24  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 25  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 26  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 27  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 28  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 29  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 30  57.13333 18.78333  40.8              measured   BITS  5018.8073
#> 31  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 32  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 33  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 34  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 35  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 36  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 37  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 38  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 39  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 40  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 41  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 42  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 43  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 44  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 45  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 46  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 47  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 48  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 49  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 50  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 51  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 52  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 53  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 54  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 55  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 56  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 57  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 58  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 59  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 60  57.86667 19.41667  49.0 estimated_from_length   BITS  1962.0690
#> 61  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 62  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 63  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 64  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 65  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 66  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 67  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 68  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 69  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 70  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 71  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 72  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 73  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 74  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 75  56.36667 18.45000  38.0              measured   BITS   275.3690
#> 76  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 77  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 78  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 79  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 80  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 81  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 82  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 83  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 84  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 85  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 86  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 87  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 88  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 89  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 90  55.91667 18.66667 113.0              measured   BITS  9830.2637
#> 91  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 92  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 93  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 94  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 95  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 96  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 97  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 98  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 99  55.68333 14.83333  57.0              measured   BITS   872.0721
#> 100 55.68333 14.83333  57.0              measured   BITS   872.0721
#> 101 55.68333 14.83333  57.0              measured   BITS   872.0721
#> 102 55.68333 14.83333  57.0              measured   BITS   872.0721
#> 103 55.68333 14.83333  57.0              measured   BITS   872.0721
#> 104 55.68333 14.83333  57.0              measured   BITS   872.0721
#> 105 55.68333 14.83333  57.0              measured   BITS   872.0721
#> 106 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 107 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 108 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 109 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 110 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 111 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 112 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 113 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 114 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 115 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 116 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 117 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 118 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 119 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 120 55.80000 15.25000  52.0              measured   BITS  1351.4823
#> 121 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 122 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 123 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 124 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 125 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 126 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 127 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 128 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 129 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 130 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 131 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 132 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 133 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 134 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 135 55.60000 14.60000  65.0              measured   BITS   403.2579
#> 136 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 137 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 138 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 139 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 140 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 141 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 142 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 143 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 144 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 145 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 146 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 147 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 148 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 149 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 150 55.68333 14.35000  34.0              measured   BITS   405.5710
#> 151 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 152 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 153 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 154 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 155 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 156 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 157 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 158 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 159 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 160 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 161 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 162 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 163 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 164 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 165 55.70000 14.36667  37.0              measured   BITS  2428.5714
#> 166 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 167 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 168 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 169 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 170 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 171 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 172 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 173 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 174 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 175 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 176 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 177 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 178 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 179 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 180 55.68333 14.45000  49.0              measured   BITS  2550.6742
#> 181 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 182 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 183 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 184 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 185 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 186 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 187 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 188 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 189 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 190 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 191 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 192 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 193 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 194 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 195 55.68333 14.50000  46.0              measured   BITS  1147.2000
#> 196 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 197 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 198 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 199 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 200 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 201 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 202 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 203 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 204 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 205 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 206 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 207 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 208 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 209 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 210 55.70000 14.36667  37.0              measured   BITS  1373.9846
#> 211 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 212 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 213 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 214 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 215 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 216 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 217 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 218 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 219 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 220 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 221 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 222 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 223 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 224 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 225 56.38333 18.48333  36.0              measured   BITS  1131.2849
#> 226 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 227 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 228 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 229 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 230 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 231 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 232 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 233 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 234 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 235 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 236 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 237 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 238 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 239 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 240 56.33333 18.43333  41.0              measured   BITS  1124.8833
#> 241 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 242 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 243 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 244 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 245 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 246 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 247 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 248 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 249 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 250 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 251 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 252 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 253 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 254 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 255 55.85000 15.56667  34.0              measured   BITS   658.5475
#> 256 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 257 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 258 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 259 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 260 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 261 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 262 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 263 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 264 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 265 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 266 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 267 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 268 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 269 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 270 55.68333 14.45000  44.0              measured   BITS  1978.4467
#> 271 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 272 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 273 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 274 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 275 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 276 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 277 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 278 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 279 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 280 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 281 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 282 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 283 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 284 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 285 55.45000 14.51667  58.0              measured   BITS 22007.4419
#> 286 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 287 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 288 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 289 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 290 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 291 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 292 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 293 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 294 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 295 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 296 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 297 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 298 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 299 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 300 55.68333 14.36667  34.7              measured   BITS  2146.8571
#> 301 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 302 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 303 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 304 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 305 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 306 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 307 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 308 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 309 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 310 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 311 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 312 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 313 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 314 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 315 55.45000 14.51667  57.0              measured   BITS  4702.1503
#> 316 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 317 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 318 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 319 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 320 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 321 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 322 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 323 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 324 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 325 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 326 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 327 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 328 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 329 55.46667 14.65000  67.0              measured   BITS  3260.8137
#> 330 55.46667 14.65000  67.0              measured   BITS  3260.8137
#>      lcod_kg_km2  scod_kg_km2             prey_group tot_prey_weight
#> 1   41403.147917 1.202027e+04          amphipoda_tot            0.00
#> 2   41403.147917 1.202027e+04           bivalvia_tot            0.00
#> 3   41403.147917 1.202027e+04          clupeidae_tot            0.00
#> 4   41403.147917 1.202027e+04    clupea_harengus_tot            0.00
#> 5   41403.147917 1.202027e+04       gadus_morhua_tot            0.00
#> 6   41403.147917 1.202027e+04           gobiidae_tot            0.00
#> 7   41403.147917 1.202027e+04            mysidae_tot            0.00
#> 8   41403.147917 1.202027e+04            non_bio_tot            0.00
#> 9   41403.147917 1.202027e+04    other_crustacea_tot            0.00
#> 10  41403.147917 1.202027e+04              other_tot            0.00
#> 11  41403.147917 1.202027e+04       other_pisces_tot            0.00
#> 12  41403.147917 1.202027e+04 platichthys_flesus_tot            0.00
#> 13  41403.147917 1.202027e+04         polychaeta_tot            0.00
#> 14  41403.147917 1.202027e+04    saduria_entomon_tot            0.00
#> 15  41403.147917 1.202027e+04  sprattus_sprattus_tot            0.00
#> 16     43.192661 1.295780e+02          amphipoda_tot            0.00
#> 17     43.192661 1.295780e+02           bivalvia_tot            0.00
#> 18     43.192661 1.295780e+02          clupeidae_tot            0.00
#> 19     43.192661 1.295780e+02    clupea_harengus_tot            0.00
#> 20     43.192661 1.295780e+02       gadus_morhua_tot            0.00
#> 21     43.192661 1.295780e+02           gobiidae_tot            0.00
#> 22     43.192661 1.295780e+02            mysidae_tot            0.01
#> 23     43.192661 1.295780e+02            non_bio_tot            0.00
#> 24     43.192661 1.295780e+02    other_crustacea_tot            0.00
#> 25     43.192661 1.295780e+02              other_tot            0.00
#> 26     43.192661 1.295780e+02       other_pisces_tot            0.00
#> 27     43.192661 1.295780e+02 platichthys_flesus_tot            0.00
#> 28     43.192661 1.295780e+02         polychaeta_tot            0.00
#> 29     43.192661 1.295780e+02    saduria_entomon_tot            0.00
#> 30     43.192661 1.295780e+02  sprattus_sprattus_tot            0.00
#> 31      0.000000 4.612069e-01          amphipoda_tot            0.00
#> 32      0.000000 4.612069e-01           bivalvia_tot            0.00
#> 33      0.000000 4.612069e-01          clupeidae_tot            0.00
#> 34      0.000000 4.612069e-01    clupea_harengus_tot            0.00
#> 35      0.000000 4.612069e-01       gadus_morhua_tot            0.00
#> 36      0.000000 4.612069e-01           gobiidae_tot            0.00
#> 37      0.000000 4.612069e-01            mysidae_tot            0.05
#> 38      0.000000 4.612069e-01            non_bio_tot            0.00
#> 39      0.000000 4.612069e-01    other_crustacea_tot            0.00
#> 40      0.000000 4.612069e-01              other_tot            0.00
#> 41      0.000000 4.612069e-01       other_pisces_tot            0.00
#> 42      0.000000 4.612069e-01 platichthys_flesus_tot            0.00
#> 43      0.000000 4.612069e-01         polychaeta_tot            0.00
#> 44      0.000000 4.612069e-01    saduria_entomon_tot            0.00
#> 45      0.000000 4.612069e-01  sprattus_sprattus_tot            0.00
#> 46      0.000000 4.612069e-01          amphipoda_tot            0.00
#> 47      0.000000 4.612069e-01           bivalvia_tot            0.00
#> 48      0.000000 4.612069e-01          clupeidae_tot            0.00
#> 49      0.000000 4.612069e-01    clupea_harengus_tot            0.00
#> 50      0.000000 4.612069e-01       gadus_morhua_tot            0.00
#> 51      0.000000 4.612069e-01           gobiidae_tot            0.00
#> 52      0.000000 4.612069e-01            mysidae_tot            0.00
#> 53      0.000000 4.612069e-01            non_bio_tot            0.00
#> 54      0.000000 4.612069e-01    other_crustacea_tot            0.00
#> 55      0.000000 4.612069e-01              other_tot            0.00
#> 56      0.000000 4.612069e-01       other_pisces_tot            0.00
#> 57      0.000000 4.612069e-01 platichthys_flesus_tot            0.00
#> 58      0.000000 4.612069e-01         polychaeta_tot            0.02
#> 59      0.000000 4.612069e-01    saduria_entomon_tot            0.00
#> 60      0.000000 4.612069e-01  sprattus_sprattus_tot            0.00
#> 61      4.447837 6.671756e+00          amphipoda_tot            0.00
#> 62      4.447837 6.671756e+00           bivalvia_tot            0.00
#> 63      4.447837 6.671756e+00          clupeidae_tot            0.00
#> 64      4.447837 6.671756e+00    clupea_harengus_tot            0.00
#> 65      4.447837 6.671756e+00       gadus_morhua_tot            0.00
#> 66      4.447837 6.671756e+00           gobiidae_tot            0.00
#> 67      4.447837 6.671756e+00            mysidae_tot            0.05
#> 68      4.447837 6.671756e+00            non_bio_tot            0.00
#> 69      4.447837 6.671756e+00    other_crustacea_tot            0.00
#> 70      4.447837 6.671756e+00              other_tot            0.00
#> 71      4.447837 6.671756e+00       other_pisces_tot            0.00
#> 72      4.447837 6.671756e+00 platichthys_flesus_tot            0.00
#> 73      4.447837 6.671756e+00         polychaeta_tot            0.00
#> 74      4.447837 6.671756e+00    saduria_entomon_tot            0.00
#> 75      4.447837 6.671756e+00  sprattus_sprattus_tot            0.00
#> 76  41903.529412 8.380706e+03          amphipoda_tot            0.00
#> 77  41903.529412 8.380706e+03           bivalvia_tot            0.00
#> 78  41903.529412 8.380706e+03          clupeidae_tot            0.00
#> 79  41903.529412 8.380706e+03    clupea_harengus_tot            0.00
#> 80  41903.529412 8.380706e+03       gadus_morhua_tot            0.00
#> 81  41903.529412 8.380706e+03           gobiidae_tot            0.00
#> 82  41903.529412 8.380706e+03            mysidae_tot            0.00
#> 83  41903.529412 8.380706e+03            non_bio_tot            0.00
#> 84  41903.529412 8.380706e+03    other_crustacea_tot            0.00
#> 85  41903.529412 8.380706e+03              other_tot            0.00
#> 86  41903.529412 8.380706e+03       other_pisces_tot            0.00
#> 87  41903.529412 8.380706e+03 platichthys_flesus_tot            0.00
#> 88  41903.529412 8.380706e+03         polychaeta_tot            0.02
#> 89  41903.529412 8.380706e+03    saduria_entomon_tot            0.00
#> 90  41903.529412 8.380706e+03  sprattus_sprattus_tot            0.00
#> 91   6429.360360 2.707099e+03          amphipoda_tot            0.00
#> 92   6429.360360 2.707099e+03           bivalvia_tot            0.00
#> 93   6429.360360 2.707099e+03          clupeidae_tot            0.00
#> 94   6429.360360 2.707099e+03    clupea_harengus_tot            0.00
#> 95   6429.360360 2.707099e+03       gadus_morhua_tot            0.00
#> 96   6429.360360 2.707099e+03           gobiidae_tot            0.00
#> 97   6429.360360 2.707099e+03            mysidae_tot            0.00
#> 98   6429.360360 2.707099e+03            non_bio_tot            0.00
#> 99   6429.360360 2.707099e+03    other_crustacea_tot            0.00
#> 100  6429.360360 2.707099e+03              other_tot            0.00
#> 101  6429.360360 2.707099e+03       other_pisces_tot            0.00
#> 102  6429.360360 2.707099e+03 platichthys_flesus_tot            0.00
#> 103  6429.360360 2.707099e+03         polychaeta_tot            0.00
#> 104  6429.360360 2.707099e+03    saduria_entomon_tot            0.00
#> 105  6429.360360 2.707099e+03  sprattus_sprattus_tot            0.00
#> 106  9580.918580 5.546848e+03          amphipoda_tot            0.00
#> 107  9580.918580 5.546848e+03           bivalvia_tot            0.00
#> 108  9580.918580 5.546848e+03          clupeidae_tot            0.00
#> 109  9580.918580 5.546848e+03    clupea_harengus_tot            0.00
#> 110  9580.918580 5.546848e+03       gadus_morhua_tot            0.00
#> 111  9580.918580 5.546848e+03           gobiidae_tot            0.00
#> 112  9580.918580 5.546848e+03            mysidae_tot            0.00
#> 113  9580.918580 5.546848e+03            non_bio_tot            0.00
#> 114  9580.918580 5.546848e+03    other_crustacea_tot            0.00
#> 115  9580.918580 5.546848e+03              other_tot            0.00
#> 116  9580.918580 5.546848e+03       other_pisces_tot            0.00
#> 117  9580.918580 5.546848e+03 platichthys_flesus_tot            0.00
#> 118  9580.918580 5.546848e+03         polychaeta_tot            0.00
#> 119  9580.918580 5.546848e+03    saduria_entomon_tot            0.00
#> 120  9580.918580 5.546848e+03  sprattus_sprattus_tot            0.00
#> 121 10913.343891 3.795946e+03          amphipoda_tot            0.00
#> 122 10913.343891 3.795946e+03           bivalvia_tot            0.00
#> 123 10913.343891 3.795946e+03          clupeidae_tot            0.00
#> 124 10913.343891 3.795946e+03    clupea_harengus_tot            0.00
#> 125 10913.343891 3.795946e+03       gadus_morhua_tot            0.00
#> 126 10913.343891 3.795946e+03           gobiidae_tot            0.00
#> 127 10913.343891 3.795946e+03            mysidae_tot            0.00
#> 128 10913.343891 3.795946e+03            non_bio_tot            0.00
#> 129 10913.343891 3.795946e+03    other_crustacea_tot            0.00
#> 130 10913.343891 3.795946e+03              other_tot            0.00
#> 131 10913.343891 3.795946e+03       other_pisces_tot            0.00
#> 132 10913.343891 3.795946e+03 platichthys_flesus_tot            0.00
#> 133 10913.343891 3.795946e+03         polychaeta_tot            0.01
#> 134 10913.343891 3.795946e+03    saduria_entomon_tot            0.00
#> 135 10913.343891 3.795946e+03  sprattus_sprattus_tot            0.00
#> 136  3745.626741 5.618440e+02          amphipoda_tot            0.00
#> 137  3745.626741 5.618440e+02           bivalvia_tot            0.00
#> 138  3745.626741 5.618440e+02          clupeidae_tot            0.00
#> 139  3745.626741 5.618440e+02    clupea_harengus_tot            0.00
#> 140  3745.626741 5.618440e+02       gadus_morhua_tot            0.00
#> 141  3745.626741 5.618440e+02           gobiidae_tot            0.00
#> 142  3745.626741 5.618440e+02            mysidae_tot            0.06
#> 143  3745.626741 5.618440e+02            non_bio_tot            0.00
#> 144  3745.626741 5.618440e+02    other_crustacea_tot            0.00
#> 145  3745.626741 5.618440e+02              other_tot            0.00
#> 146  3745.626741 5.618440e+02       other_pisces_tot            0.00
#> 147  3745.626741 5.618440e+02 platichthys_flesus_tot            0.00
#> 148  3745.626741 5.618440e+02         polychaeta_tot            0.00
#> 149  3745.626741 5.618440e+02    saduria_entomon_tot            0.00
#> 150  3745.626741 5.618440e+02  sprattus_sprattus_tot            0.00
#> 151  3898.476190 2.598984e+03          amphipoda_tot            0.00
#> 152  3898.476190 2.598984e+03           bivalvia_tot            0.00
#> 153  3898.476190 2.598984e+03          clupeidae_tot            0.00
#> 154  3898.476190 2.598984e+03    clupea_harengus_tot            0.00
#> 155  3898.476190 2.598984e+03       gadus_morhua_tot            0.00
#> 156  3898.476190 2.598984e+03           gobiidae_tot            0.00
#> 157  3898.476190 2.598984e+03            mysidae_tot            0.03
#> 158  3898.476190 2.598984e+03            non_bio_tot            0.00
#> 159  3898.476190 2.598984e+03    other_crustacea_tot            0.00
#> 160  3898.476190 2.598984e+03              other_tot            0.00
#> 161  3898.476190 2.598984e+03       other_pisces_tot            0.00
#> 162  3898.476190 2.598984e+03 platichthys_flesus_tot            0.00
#> 163  3898.476190 2.598984e+03         polychaeta_tot            0.00
#> 164  3898.476190 2.598984e+03    saduria_entomon_tot            0.00
#> 165  3898.476190 2.598984e+03  sprattus_sprattus_tot            0.00
#> 166  5357.123596 5.059506e+03          amphipoda_tot            0.00
#> 167  5357.123596 5.059506e+03           bivalvia_tot            0.00
#> 168  5357.123596 5.059506e+03          clupeidae_tot            0.00
#> 169  5357.123596 5.059506e+03    clupea_harengus_tot            0.00
#> 170  5357.123596 5.059506e+03       gadus_morhua_tot            0.00
#> 171  5357.123596 5.059506e+03           gobiidae_tot            0.00
#> 172  5357.123596 5.059506e+03            mysidae_tot            0.03
#> 173  5357.123596 5.059506e+03            non_bio_tot            0.00
#> 174  5357.123596 5.059506e+03    other_crustacea_tot            0.00
#> 175  5357.123596 5.059506e+03              other_tot            0.00
#> 176  5357.123596 5.059506e+03       other_pisces_tot            0.00
#> 177  5357.123596 5.059506e+03 platichthys_flesus_tot            0.00
#> 178  5357.123596 5.059506e+03         polychaeta_tot            0.00
#> 179  5357.123596 5.059506e+03    saduria_entomon_tot            0.00
#> 180  5357.123596 5.059506e+03  sprattus_sprattus_tot            0.00
#> 181  5888.715000 5.195925e+03          amphipoda_tot            0.00
#> 182  5888.715000 5.195925e+03           bivalvia_tot            0.00
#> 183  5888.715000 5.195925e+03          clupeidae_tot            0.00
#> 184  5888.715000 5.195925e+03    clupea_harengus_tot            0.00
#> 185  5888.715000 5.195925e+03       gadus_morhua_tot            0.00
#> 186  5888.715000 5.195925e+03           gobiidae_tot            0.00
#> 187  5888.715000 5.195925e+03            mysidae_tot            0.03
#> 188  5888.715000 5.195925e+03            non_bio_tot            0.00
#> 189  5888.715000 5.195925e+03    other_crustacea_tot            0.00
#> 190  5888.715000 5.195925e+03              other_tot            0.00
#> 191  5888.715000 5.195925e+03       other_pisces_tot            0.00
#> 192  5888.715000 5.195925e+03 platichthys_flesus_tot            0.00
#> 193  5888.715000 5.195925e+03         polychaeta_tot            0.00
#> 194  5888.715000 5.195925e+03    saduria_entomon_tot            0.00
#> 195  5888.715000 5.195925e+03  sprattus_sprattus_tot            0.00
#> 196  4357.403599 3.195429e+03          amphipoda_tot            0.00
#> 197  4357.403599 3.195429e+03           bivalvia_tot            0.00
#> 198  4357.403599 3.195429e+03          clupeidae_tot            0.00
#> 199  4357.403599 3.195429e+03    clupea_harengus_tot            0.00
#> 200  4357.403599 3.195429e+03       gadus_morhua_tot            0.00
#> 201  4357.403599 3.195429e+03           gobiidae_tot            0.00
#> 202  4357.403599 3.195429e+03            mysidae_tot            0.09
#> 203  4357.403599 3.195429e+03            non_bio_tot            0.00
#> 204  4357.403599 3.195429e+03    other_crustacea_tot            0.00
#> 205  4357.403599 3.195429e+03              other_tot            0.00
#> 206  4357.403599 3.195429e+03       other_pisces_tot            0.00
#> 207  4357.403599 3.195429e+03 platichthys_flesus_tot            0.00
#> 208  4357.403599 3.195429e+03         polychaeta_tot            0.01
#> 209  4357.403599 3.195429e+03    saduria_entomon_tot            0.00
#> 210  4357.403599 3.195429e+03  sprattus_sprattus_tot            0.00
#> 211    18.212291 1.365922e+01          amphipoda_tot            0.00
#> 212    18.212291 1.365922e+01           bivalvia_tot            0.00
#> 213    18.212291 1.365922e+01          clupeidae_tot            0.00
#> 214    18.212291 1.365922e+01    clupea_harengus_tot            0.00
#> 215    18.212291 1.365922e+01       gadus_morhua_tot            0.00
#> 216    18.212291 1.365922e+01           gobiidae_tot            0.00
#> 217    18.212291 1.365922e+01            mysidae_tot            0.11
#> 218    18.212291 1.365922e+01            non_bio_tot            0.00
#> 219    18.212291 1.365922e+01    other_crustacea_tot            0.00
#> 220    18.212291 1.365922e+01              other_tot            0.00
#> 221    18.212291 1.365922e+01       other_pisces_tot            0.00
#> 222    18.212291 1.365922e+01 platichthys_flesus_tot            0.00
#> 223    18.212291 1.365922e+01         polychaeta_tot            0.00
#> 224    18.212291 1.365922e+01    saduria_entomon_tot            0.00
#> 225    18.212291 1.365922e+01  sprattus_sprattus_tot            0.00
#> 226    43.933333 2.928889e+01          amphipoda_tot            0.00
#> 227    43.933333 2.928889e+01           bivalvia_tot            0.00
#> 228    43.933333 2.928889e+01          clupeidae_tot            0.00
#> 229    43.933333 2.928889e+01    clupea_harengus_tot            0.00
#> 230    43.933333 2.928889e+01       gadus_morhua_tot            0.00
#> 231    43.933333 2.928889e+01           gobiidae_tot            0.00
#> 232    43.933333 2.928889e+01            mysidae_tot            0.03
#> 233    43.933333 2.928889e+01            non_bio_tot            0.00
#> 234    43.933333 2.928889e+01    other_crustacea_tot            0.00
#> 235    43.933333 2.928889e+01              other_tot            0.00
#> 236    43.933333 2.928889e+01       other_pisces_tot            0.00
#> 237    43.933333 2.928889e+01 platichthys_flesus_tot            0.00
#> 238    43.933333 2.928889e+01         polychaeta_tot            0.00
#> 239    43.933333 2.928889e+01    saduria_entomon_tot            0.00
#> 240    43.933333 2.928889e+01  sprattus_sprattus_tot            0.00
#> 241    26.078212 6.519553e+01          amphipoda_tot            0.00
#> 242    26.078212 6.519553e+01           bivalvia_tot            0.00
#> 243    26.078212 6.519553e+01          clupeidae_tot            0.00
#> 244    26.078212 6.519553e+01    clupea_harengus_tot            0.00
#> 245    26.078212 6.519553e+01       gadus_morhua_tot            0.00
#> 246    26.078212 6.519553e+01           gobiidae_tot            0.00
#> 247    26.078212 6.519553e+01            mysidae_tot            0.00
#> 248    26.078212 6.519553e+01            non_bio_tot            0.00
#> 249    26.078212 6.519553e+01    other_crustacea_tot            0.01
#> 250    26.078212 6.519553e+01              other_tot            0.00
#> 251    26.078212 6.519553e+01       other_pisces_tot            0.00
#> 252    26.078212 6.519553e+01 platichthys_flesus_tot            0.00
#> 253    26.078212 6.519553e+01         polychaeta_tot            0.00
#> 254    26.078212 6.519553e+01    saduria_entomon_tot            0.00
#> 255    26.078212 6.519553e+01  sprattus_sprattus_tot            0.00
#> 256  5249.883249 4.420954e+03          amphipoda_tot            0.00
#> 257  5249.883249 4.420954e+03           bivalvia_tot            0.00
#> 258  5249.883249 4.420954e+03          clupeidae_tot            0.00
#> 259  5249.883249 4.420954e+03    clupea_harengus_tot            0.00
#> 260  5249.883249 4.420954e+03       gadus_morhua_tot            0.00
#> 261  5249.883249 4.420954e+03           gobiidae_tot            0.00
#> 262  5249.883249 4.420954e+03            mysidae_tot            0.05
#> 263  5249.883249 4.420954e+03            non_bio_tot            0.00
#> 264  5249.883249 4.420954e+03    other_crustacea_tot            0.00
#> 265  5249.883249 4.420954e+03              other_tot            0.00
#> 266  5249.883249 4.420954e+03       other_pisces_tot            0.00
#> 267  5249.883249 4.420954e+03 platichthys_flesus_tot            0.00
#> 268  5249.883249 4.420954e+03         polychaeta_tot            0.00
#> 269  5249.883249 4.420954e+03    saduria_entomon_tot            0.00
#> 270  5249.883249 4.420954e+03  sprattus_sprattus_tot            0.00
#> 271  7913.255814 6.782791e+03          amphipoda_tot            0.00
#> 272  7913.255814 6.782791e+03           bivalvia_tot            0.00
#> 273  7913.255814 6.782791e+03          clupeidae_tot            0.00
#> 274  7913.255814 6.782791e+03    clupea_harengus_tot            0.00
#> 275  7913.255814 6.782791e+03       gadus_morhua_tot            0.00
#> 276  7913.255814 6.782791e+03           gobiidae_tot            0.00
#> 277  7913.255814 6.782791e+03            mysidae_tot            0.01
#> 278  7913.255814 6.782791e+03            non_bio_tot            0.00
#> 279  7913.255814 6.782791e+03    other_crustacea_tot            0.00
#> 280  7913.255814 6.782791e+03              other_tot            0.00
#> 281  7913.255814 6.782791e+03       other_pisces_tot            0.00
#> 282  7913.255814 6.782791e+03 platichthys_flesus_tot            0.00
#> 283  7913.255814 6.782791e+03         polychaeta_tot            0.00
#> 284  7913.255814 6.782791e+03    saduria_entomon_tot            0.00
#> 285  7913.255814 6.782791e+03  sprattus_sprattus_tot            0.00
#> 286  4007.854545 2.504909e+03          amphipoda_tot            0.00
#> 287  4007.854545 2.504909e+03           bivalvia_tot            0.00
#> 288  4007.854545 2.504909e+03          clupeidae_tot            0.00
#> 289  4007.854545 2.504909e+03    clupea_harengus_tot            0.00
#> 290  4007.854545 2.504909e+03       gadus_morhua_tot            0.00
#> 291  4007.854545 2.504909e+03           gobiidae_tot            0.00
#> 292  4007.854545 2.504909e+03            mysidae_tot            0.02
#> 293  4007.854545 2.504909e+03            non_bio_tot            0.00
#> 294  4007.854545 2.504909e+03    other_crustacea_tot            0.00
#> 295  4007.854545 2.504909e+03              other_tot            0.00
#> 296  4007.854545 2.504909e+03       other_pisces_tot            0.00
#> 297  4007.854545 2.504909e+03 platichthys_flesus_tot            0.00
#> 298  4007.854545 2.504909e+03         polychaeta_tot            0.00
#> 299  4007.854545 2.504909e+03    saduria_entomon_tot            0.00
#> 300  4007.854545 2.504909e+03  sprattus_sprattus_tot            0.00
#> 301 11382.588727 7.398683e+03          amphipoda_tot            0.00
#> 302 11382.588727 7.398683e+03           bivalvia_tot            0.00
#> 303 11382.588727 7.398683e+03          clupeidae_tot            0.00
#> 304 11382.588727 7.398683e+03    clupea_harengus_tot            0.00
#> 305 11382.588727 7.398683e+03       gadus_morhua_tot            0.00
#> 306 11382.588727 7.398683e+03           gobiidae_tot            0.00
#> 307 11382.588727 7.398683e+03            mysidae_tot            0.00
#> 308 11382.588727 7.398683e+03            non_bio_tot            0.00
#> 309 11382.588727 7.398683e+03    other_crustacea_tot            0.00
#> 310 11382.588727 7.398683e+03              other_tot            0.00
#> 311 11382.588727 7.398683e+03       other_pisces_tot            0.00
#> 312 11382.588727 7.398683e+03 platichthys_flesus_tot            0.00
#> 313 11382.588727 7.398683e+03         polychaeta_tot            0.01
#> 314 11382.588727 7.398683e+03    saduria_entomon_tot            0.00
#> 315 11382.588727 7.398683e+03  sprattus_sprattus_tot            0.00
#> 316  9313.785867 3.449550e+03          amphipoda_tot            0.00
#> 317  9313.785867 3.449550e+03           bivalvia_tot            0.00
#> 318  9313.785867 3.449550e+03          clupeidae_tot            0.00
#> 319  9313.785867 3.449550e+03    clupea_harengus_tot            0.00
#> 320  9313.785867 3.449550e+03       gadus_morhua_tot            0.00
#> 321  9313.785867 3.449550e+03           gobiidae_tot            0.00
#> 322  9313.785867 3.449550e+03            mysidae_tot            0.00
#> 323  9313.785867 3.449550e+03            non_bio_tot            0.00
#> 324  9313.785867 3.449550e+03    other_crustacea_tot            0.01
#> 325  9313.785867 3.449550e+03              other_tot            0.00
#> 326  9313.785867 3.449550e+03       other_pisces_tot            0.00
#> 327  9313.785867 3.449550e+03 platichthys_flesus_tot            0.00
#> 328  9313.785867 3.449550e+03         polychaeta_tot            0.02
#> 329  9313.785867 3.449550e+03    saduria_entomon_tot            0.00
#> 330  9313.785867 3.449550e+03  sprattus_sprattus_tot            0.00

max_size_cod <- 65

cod_important_prey3 <- long_cod %>%
  mutate(pred_length_cm2 = ifelse(pred_length_cm > max_size_cod, max_size_cod -1, pred_length_cm)) %>% 
  mutate(predator_length_grp = cut(pred_length_cm2, breaks = seq(0, 100, by = 5))) %>% 
  group_by(prey_group, predator_length_grp) %>%
  summarise(prey_group_tot = sum(tot_prey_weight)) %>% 
  ungroup() %>% 
  group_by(predator_length_grp) %>% 
  mutate(prop = prey_group_tot / sum(prey_group_tot)) %>% 
  ungroup() %>%
  mutate(max_size = as.numeric(substr(predator_length_grp, 5, 6)),
         max_size = ifelse(predator_length_grp == "(0,5]", 5, max_size),
         max_size = ifelse(predator_length_grp == "(5,10]", 10, max_size),
         predator = "Cod")
#> mutate: new variable 'pred_length_cm2' (double) with 62 unique values and 0% NA
#> mutate: new variable 'predator_length_grp' (factor) with 13 unique values and 0% NA
#> group_by: 2 grouping variables (prey_group, predator_length_grp)
#> summarise: now 195 rows and 3 columns, one group variable remaining (prey_group)
#> ungroup: no grouping variables
#> group_by: one grouping variable (predator_length_grp)
#> mutate (grouped): new variable 'prop' (double) with 144 unique values and 0% NA
#> ungroup: no grouping variables
#> Warning in mask$eval_all_mutate(quo): NAs introduced by coercion
#> mutate: new variable 'max_size' (double) with 13 unique values and 0% NA
#>         new variable 'predator' (character) with one unique value and 0% NA

max_size_fle = 40

fle_important_prey3 <- long_fle %>%
  mutate(pred_length_cm2 = ifelse(pred_length_cm > max_size_fle, max_size_fle-1, pred_length_cm)) %>% 
  mutate(predator_length_grp = cut(pred_length_cm2, breaks = seq(0, 100, by = 5))) %>% 
  group_by(prey_group, predator_length_grp) %>%
  summarise(prey_group_tot = sum(tot_prey_weight)) %>% 
  ungroup() %>% 
  group_by(predator_length_grp) %>% 
  mutate(prop = prey_group_tot / sum(prey_group_tot)) %>% 
  ungroup() %>%
  mutate(max_size = as.numeric(substr(predator_length_grp, 5, 6)),
         max_size = ifelse(predator_length_grp == "(0,5]", 5, max_size),
         max_size = ifelse(predator_length_grp == "(5,10]", 10, max_size),
         predator = "Flounder")
#> mutate: new variable 'pred_length_cm2' (double) with 31 unique values and 0% NA
#> mutate: new variable 'predator_length_grp' (factor) with 7 unique values and 0% NA
#> group_by: 2 grouping variables (prey_group, predator_length_grp)
#> summarise: now 105 rows and 3 columns, one group variable remaining (prey_group)
#> ungroup: no grouping variables
#> group_by: one grouping variable (predator_length_grp)
#> mutate (grouped): new variable 'prop' (double) with 70 unique values and 0% NA
#> ungroup: no grouping variables
#> Warning in mask$eval_all_mutate(quo): NAs introduced by coercion
#> mutate: new variable 'max_size' (double) with 7 unique values and 0% NA
#>         new variable 'predator' (character) with one unique value and 0% NA

area_plot <- bind_rows(fle_important_prey3, cod_important_prey3) %>% 
  mutate(prop = replace_na(prop, 0))
#> mutate: no changes

n_cat <- nrow(area_plot %>% distinct(prey_group))
#> distinct: removed 285 rows (95%), 15 rows remaining
colourCount <- n_cat
getPalette <- colorRampPalette(brewer.pal(12, "Paired"))
pal <- getPalette(colourCount)

area_plot %>% distinct(prey_group)
#> distinct: removed 285 rows (95%), 15 rows remaining
#> # A tibble: 15 × 1
#>    prey_group            
#>    <chr>                 
#>  1 amphipoda_tot         
#>  2 bivalvia_tot          
#>  3 clupea_harengus_tot   
#>  4 clupeidae_tot         
#>  5 gadus_morhua_tot      
#>  6 gobiidae_tot          
#>  7 mysidae_tot           
#>  8 non_bio_tot           
#>  9 other_crustacea_tot   
#> 10 other_pisces_tot      
#> 11 other_tot             
#> 12 platichthys_flesus_tot
#> 13 polychaeta_tot        
#> 14 saduria_entomon_tot   
#> 15 sprattus_sprattus_tot

area_plot <- area_plot %>%
  mutate(prey_group = ifelse(prey_group == "amphipoda_tot", "Amphipoda", prey_group),
         prey_group = ifelse(prey_group == "bivalvia_tot", "Bivalvia", prey_group),
         prey_group = ifelse(prey_group == "clupea_harengus_tot", "Clupea harengus", prey_group),
         prey_group = ifelse(prey_group == "clupeidae_tot", "Clupeidae", prey_group),
         prey_group = ifelse(prey_group == "gadus_morhua_tot", "Gadus morhua", prey_group),
         prey_group = ifelse(prey_group == "gobiidae_tot", "Gobiidae", prey_group),
         prey_group = ifelse(prey_group == "mysidae_tot", "Mysidae", prey_group),
         prey_group = ifelse(prey_group == "non_bio_tot", "Non-bio", prey_group),
         prey_group = ifelse(prey_group == "other_crustacea_tot", "Other crustacea", prey_group),
         prey_group = ifelse(prey_group == "other_pisces_tot", "Other pisces", prey_group),
         prey_group = ifelse(prey_group == "other_tot", "Other", prey_group),
         prey_group = ifelse(prey_group == "platichthys_flesus_tot", "Platichthys flesus", prey_group),
         prey_group = ifelse(prey_group == "polychaeta_tot", "Polychaeta", prey_group),
         prey_group = ifelse(prey_group == "saduria_entomon_tot", "Saduria entomon", prey_group),
         prey_group = ifelse(prey_group == "sprattus_sprattus_tot", "Sprattus sprattus", prey_group))
#> mutate: changed 300 values (100%) of 'prey_group' (0 new NA)

# fill_order <- factor(area_plot$prey_group,
#                      levels =  c("Sprattus sprattus", "Clupea harengus", "Clupeidae",
#                                  "Gobiidae", "Other pisces", "Gadiformes", "Gadus morhua",
#                                  "Platichthys flesus", "Amphipoda", "Bivalvia", "Mysidae",
#                                  "Polychaeta", "Saduria entomon", "Other crustacea",
#                                  "Other", "Non-bio"))

# Dataframes for geom_text with sample size
n_cod <- long_cod %>%
  mutate(pred_length_cm2 = ifelse(pred_length_cm > max_size_cod, max_size_cod -1, pred_length_cm)) %>% 
  mutate(predator_length_grp = cut(pred_length_cm2, breaks = seq(0, 100, by = 5))) %>% 
  group_by(predator_length_grp) %>%
  summarise(n = length(unique(pred_id)))
#> mutate: new variable 'pred_length_cm2' (double) with 62 unique values and 0% NA
#> mutate: new variable 'predator_length_grp' (factor) with 13 unique values and 0% NA
#> group_by: one grouping variable (predator_length_grp)
#> summarise: now 13 rows and 2 columns, ungrouped

n_fle <- long_fle %>%
  mutate(pred_length_cm2 = ifelse(pred_length_cm > max_size_fle, max_size_fle-1, pred_length_cm)) %>% 
  mutate(predator_length_grp = cut(pred_length_cm2, breaks = seq(0, 100, by = 5))) %>% 
  group_by(predator_length_grp) %>%
  summarise(n = length(unique(pred_id)))
#> mutate: new variable 'pred_length_cm2' (double) with 31 unique values and 0% NA
#> mutate: new variable 'predator_length_grp' (factor) with 7 unique values and 0% NA
#> group_by: one grouping variable (predator_length_grp)
#> summarise: now 7 rows and 2 columns, ungrouped

n_dat <- bind_rows(n_cod %>% mutate(predator = "Cod"), 
                   n_fle %>% mutate(predator = "Flounder")) %>% 
  mutate(max_size = as.numeric(substr(predator_length_grp, 5, 6)),
         max_size = ifelse(predator_length_grp == "(0,5]", 5, max_size),
         max_size = ifelse(predator_length_grp == "(5,10]", 10, max_size))
#> mutate: new variable 'predator' (character) with one unique value and 0% NA
#> mutate: new variable 'predator' (character) with one unique value and 0% NA
#> Warning in mask$eval_all_mutate(quo): NAs introduced by coercion
#> mutate: new variable 'max_size' (double) with 13 unique values and 0% NA


#ggplot(data = area_plot, aes(x = min_size, y = prop, fill = fill_order, color = fill_order)) +
ggplot(data = area_plot, aes(x = max_size, y = prop, fill = prey_group, color = prey_group)) +
  geom_col(width = 4.3) +
  geom_text(data = n_dat, aes(x = max_size, y = 1.038, label = n), inherit.aes = FALSE,
            size = 0, color = "white") +
  geom_text(data = n_dat, aes(x = max_size, y = 1.02, label = n), inherit.aes = FALSE,
            size = 2) +
  facet_wrap(~predator, scales = "free") +
  scale_fill_manual(values = pal, name = "") +
  scale_color_manual(values = pal, name = "") +
  coord_cartesian(expand = 0) +
  scale_x_continuous(breaks = seq(0, 100, 5)) +
  labs(y = "Proportion", x = "Max. predator size in group [cm]") +
  theme(legend.position = "bottom",
        aspect.ratio = 1) +
  NULL


ggsave("figures/ontogenetic_diet.pdf", width = 17, height = 17, units = "cm")

Calculate response variables

# Total feeding ratio, proportion of saduria and proportion of common prey!

# Cod
wide_cod <- d_wide_cod %>% 
  drop_na(pred_weight_g) %>% 
  mutate(tot_prey_biom = amphipoda_tot + bivalvia_tot + clupeidae_tot + clupea_harengus_tot + 
             gadus_morhua_tot + gobiidae_tot + mysidae_tot + non_bio_tot + 
             other_crustacea_tot + other_tot + other_pisces_tot + platichthys_flesus_tot +
             polychaeta_tot + saduria_entomon_tot + sprattus_sprattus_tot,
         
         tot_benthic_prey_biom = amphipoda_tot + bivalvia_tot + gadus_morhua_tot +
             gobiidae_tot + mysidae_tot + non_bio_tot + 
             other_crustacea_tot + other_tot + other_pisces_tot + platichthys_flesus_tot +
             polychaeta_tot + saduria_entomon_tot,
         
         tot_sprat_biom = sprattus_sprattus_tot,
         
         tot_herring_biom = clupea_harengus_tot,
         
         tot_pelagic_biom = clupeidae_tot + clupea_harengus_tot + sprattus_sprattus_tot,
         
         tot_common_prey_biom = other_crustacea_tot + other_pisces_tot + polychaeta_tot + 
             saduria_entomon_tot + sprattus_sprattus_tot,
         
         tot_feeding_ratio = (tot_prey_biom)/(pred_weight_g - tot_prey_biom),
         
         benthic_feeding_ratio = (tot_benthic_prey_biom)/(pred_weight_g - tot_prey_biom),
         
         sprat_feeding_ratio = tot_sprat_biom/(pred_weight_g - tot_pelagic_biom),
         
         herring_feeding_ratio = tot_herring_biom/(pred_weight_g - tot_pelagic_biom),
         
         pelagic_feeding_ratio = tot_pelagic_biom/(pred_weight_g - tot_pelagic_biom),
         
         common_feeding_ratio = (tot_common_prey_biom)/(pred_weight_g - tot_prey_biom),
         
         saduria_feeding_ratio = (saduria_entomon_tot)/(pred_weight_g - tot_prey_biom)) %>% 
  filter(tot_feeding_ratio < 0.4) %>% # Seems like a reasonable cutoff
  dplyr::select(-amphipoda_tot, -bivalvia_tot, -clupeidae_tot, -clupea_harengus_tot, 
                -gadus_morhua_tot, -gobiidae_tot, -mysidae_tot, -non_bio_tot, 
                -other_crustacea_tot, -other_tot, -other_pisces_tot, -platichthys_flesus_tot,
                -polychaeta_tot, -saduria_entomon_tot, -sprattus_sprattus_tot,
                -tot_prey_biom, -tot_benthic_prey_biom, -tot_common_prey_biom, 
                -tot_pelagic_biom, -tot_sprat_biom, -tot_herring_biom)
#> drop_na: no rows removed
#> mutate: new variable 'tot_prey_biom' (double) with 1,390 unique values and 0% NA
#>         new variable 'tot_benthic_prey_biom' (double) with 773 unique values and 0% NA
#>         new variable 'tot_sprat_biom' (double) with 492 unique values and 0% NA
#>         new variable 'tot_herring_biom' (double) with 281 unique values and 0% NA
#>         new variable 'tot_pelagic_biom' (double) with 772 unique values and 0% NA
#>         new variable 'tot_common_prey_biom' (double) with 847 unique values and 0% NA
#>         new variable 'tot_feeding_ratio' (double) with 2,475 unique values and 0% NA
#>         new variable 'benthic_feeding_ratio' (double) with 1,988 unique values and 0% NA
#>         new variable 'sprat_feeding_ratio' (double) with 555 unique values and 0% NA
#>         new variable 'herring_feeding_ratio' (double) with 294 unique values and 0% NA
#>         new variable 'pelagic_feeding_ratio' (double) with 890 unique values and 0% NA
#>         new variable 'common_feeding_ratio' (double) with 1,814 unique values and 0% NA
#>         new variable 'saduria_feeding_ratio' (double) with 352 unique values and 0% NA
#> filter: removed 4 rows (<1%), 3,306 rows remaining

# Flounder  
wide_fle <- d_wide_fle %>% 
  drop_na(pred_weight_g) %>% 
  mutate(tot_prey_biom = amphipoda_tot + bivalvia_tot + clupeidae_tot + clupea_harengus_tot + 
             gadus_morhua_tot + gobiidae_tot + mysidae_tot + non_bio_tot + 
             other_crustacea_tot + other_tot + other_pisces_tot + platichthys_flesus_tot +
             polychaeta_tot + saduria_entomon_tot + sprattus_sprattus_tot,
         
         tot_benthic_prey_biom = amphipoda_tot + bivalvia_tot + gadus_morhua_tot +
             gobiidae_tot + mysidae_tot + non_bio_tot + 
             other_crustacea_tot + other_tot + other_pisces_tot + platichthys_flesus_tot +
             polychaeta_tot + saduria_entomon_tot,
         
         tot_sprat_biom = sprattus_sprattus_tot,
         
         tot_herring_biom = clupea_harengus_tot,
         
         tot_pelagic_biom = clupeidae_tot + clupea_harengus_tot + sprattus_sprattus_tot,
         
         tot_common_prey_biom = other_crustacea_tot + other_pisces_tot + polychaeta_tot + 
             saduria_entomon_tot + sprattus_sprattus_tot,
         
         tot_feeding_ratio = (tot_prey_biom)/(pred_weight_g - tot_prey_biom),
         
         benthic_feeding_ratio = (tot_benthic_prey_biom)/(pred_weight_g - tot_prey_biom),
         
         sprat_feeding_ratio = tot_sprat_biom/(pred_weight_g - tot_pelagic_biom),
         
         herring_feeding_ratio = tot_herring_biom/(pred_weight_g - tot_pelagic_biom),
         
         pelagic_feeding_ratio = tot_pelagic_biom/(pred_weight_g - tot_pelagic_biom),
         
         common_feeding_ratio = (tot_common_prey_biom)/(pred_weight_g - tot_prey_biom),
         
         saduria_feeding_ratio = (saduria_entomon_tot)/(pred_weight_g - tot_prey_biom)) %>% 
  filter(tot_feeding_ratio < 0.4) %>% # Seems like a reasonable cutoff
  dplyr::select(-amphipoda_tot, -bivalvia_tot, -clupeidae_tot, -clupea_harengus_tot, 
                -gadus_morhua_tot, -gobiidae_tot, -mysidae_tot, -non_bio_tot, 
                -other_crustacea_tot, -other_tot, -other_pisces_tot, -platichthys_flesus_tot,
                -polychaeta_tot, -saduria_entomon_tot, -sprattus_sprattus_tot,
                -tot_prey_biom, -tot_benthic_prey_biom, -tot_common_prey_biom,
                -tot_pelagic_biom, -tot_sprat_biom, -tot_herring_biom)
#> drop_na: no rows removed
#> mutate: new variable 'tot_prey_biom' (double) with 1,168 unique values and 0% NA
#>         new variable 'tot_benthic_prey_biom' (double) with 1,147 unique values and 0% NA
#>         new variable 'tot_sprat_biom' (double) with 35 unique values and 0% NA
#>         new variable 'tot_herring_biom' (double) with 7 unique values and 0% NA
#>         new variable 'tot_pelagic_biom' (double) with 44 unique values and 0% NA
#>         new variable 'tot_common_prey_biom' (double) with 657 unique values and 0% NA
#>         new variable 'tot_feeding_ratio' (double) with 1,635 unique values and 0% NA
#>         new variable 'benthic_feeding_ratio' (double) with 1,609 unique values and 0% NA
#>         new variable 'sprat_feeding_ratio' (double) with 36 unique values and 0% NA
#>         new variable 'herring_feeding_ratio' (double) with 7 unique values and 0% NA
#>         new variable 'pelagic_feeding_ratio' (double) with 47 unique values and 0% NA
#>         new variable 'common_feeding_ratio' (double) with 1,260 unique values and 0% NA
#>         new variable 'saduria_feeding_ratio' (double) with 596 unique values and 0% NA
#> filter: no rows removed

# Plot tot_feeding_ratio for all years
ggplot(wide_cod, aes(year, tot_feeding_ratio)) + 
  geom_jitter(size = 3, shape = 21, color = "white", fill = "gray30") + 
  stat_smooth(method = "gam", formula = y~s(x, k = 3)) + 
  facet_wrap(~quarter, ncol = 1, scales = "free") + 
  NULL


ggplot(wide_fle, aes(year, tot_feeding_ratio)) + 
  geom_jitter(size = 3, shape = 21, color = "white", fill = "gray30") + 
  stat_smooth(method = "gam", formula = y~s(x, k = 3)) + 
  facet_wrap(~quarter, ncol = 1, scales = "free") + 
  NULL


dat <- bind_rows(wide_fle, wide_cod)

glimpse(dat)
#> Rows: 5,885
#> Columns: 29
#> $ pred_id               <chr> "2015_4_FLE_1", "2015_4_FLE_10", "2015_4_FLE_125…
#> $ predator_latin_name   <chr> "Platichthys flesus", "Platichthys flesus", "Pla…
#> $ species               <chr> "Flounder", "Flounder", "Flounder", "Flounder", …
#> $ pred_weight_g         <dbl> 219.52, 175.76, 593.19, 428.75, 297.91, 219.52, …
#> $ pred_length_cm        <dbl> 28, 26, 39, 35, 31, 28, 27, 32, 20, 21, 24, 31, …
#> $ year                  <dbl> 2015, 2015, 2015, 2015, 2015, 2015, 2015, 2015, …
#> $ quarter               <dbl> 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, …
#> $ month                 <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, …
#> $ day                   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, …
#> $ ices_rect             <chr> "40G4", "40G4", "40G4", "40G4", "40G4", "41G7", …
#> $ subdiv                <dbl> 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, …
#> $ haul_id               <chr> "2015_4_2", "2015_4_2", "2015_4_6", "2015_4_6", …
#> $ X                     <dbl> 474.8173, 474.8173, 460.1953, 460.1953, 474.8173…
#> $ Y                     <dbl> 6165.344, 6165.344, 6172.873, 6172.873, 6165.344…
#> $ lat                   <dbl> 55.63333, 55.63333, 55.70000, 55.70000, 55.63333…
#> $ lon                   <dbl> 14.60000, 14.60000, 14.36667, 14.36667, 14.60000…
#> $ depth                 <dbl> 60.2, 60.2, 37.9, 37.9, 60.2, 41.6, 41.6, 41.6, …
#> $ pred_weight_source    <chr> "estimated_from_length", "estimated_from_length"…
#> $ cruise                <chr> "BITS", "BITS", "BITS", "BITS", "BITS", "BITS", …
#> $ fle_kg_km2            <dbl> 330.2812, 330.2812, 2226.6515, 2226.6515, 330.28…
#> $ lcod_kg_km2           <dbl> 41403.148, 41403.148, 12382.688, 12382.688, 4140…
#> $ scod_kg_km2           <dbl> 12020.269, 12020.269, 1547.836, 1547.836, 12020.…
#> $ tot_feeding_ratio     <dbl> 0.0039330467, 0.0032536104, 0.0147806005, 0.0417…
#> $ benthic_feeding_ratio <dbl> 0.0039330467, 0.0032536104, 0.0147806005, 0.0417…
#> $ sprat_feeding_ratio   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
#> $ herring_feeding_ratio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
#> $ pelagic_feeding_ratio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, …
#> $ common_feeding_ratio  <dbl> 0.0000914662, 0.0022832353, 0.0000000000, 0.0000…
#> $ saduria_feeding_ratio <dbl> 0.0000000000, 0.0000000000, 0.0000000000, 0.0000…
nrow(dat)
#> [1] 5885
length(unique(dat$pred_id))
#> [1] 5885
write_csv(dat, "data/clean/clean_stomach_data.csv")